Skip to content

common: MemoryModel: performance improvements and API changes#58115

Merged
ronen-fr merged 9 commits intoceph:mainfrom
ronen-fr:wip-rf-memmodel
Aug 5, 2024
Merged

common: MemoryModel: performance improvements and API changes#58115
ronen-fr merged 9 commits intoceph:mainfrom
ronen-fr:wip-rf-memmodel

Conversation

@ronen-fr
Copy link
Contributor

@ronen-fr ronen-fr commented Jun 18, 2024

Performance: per my off-line (code snippets) benchmarks
(see benchtest):

  • the parsing of /proc/status improved by
  1. only opening the proc file once (saves almost 40%)
  2. using charconv
  • for /proc/maps:
  1. opening once (most of the improvement);
  2. faster discarding of lines;
  3. using charconv

The API changes:

  • no output parameters;
  • no internally-maintained samples;
  • not issuing warning messages to the log directly;

The PR includes work by @athanatos & @shreekarSS,
picked from #54698

athanatos and others added 5 commits June 18, 2024 03:05
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit 720ce78)
as 'snap' as a struct name does not follow the naming convention, and
'snap' is way overloaded in the codebase.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
Allowing clients to hold on to the MemoryModel object for multiple
"snapshots", saving (per measurements) ~40% of the sampling run time.

Also: separating the parsing of /proc/maps (which consumes most of
the remaining execution time) into a separate function. This will allow
us to create a "no need for precise heap" fast mode (in a future
commit).

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
We're going to add this functionality to other components, simplify
this one first to match.

Signed-off-by: Samuel Just <sjust@redhat.com>
Signed-off-by: Shreekara <sshreeka@redhat.com>
(cherry picked from commit f337bda)
Also - stopping the parsing of /proc/status once all the needed fields
have been found,
The resulting code is measurably faster than the previous version.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
@github-actions github-actions bot added cephfs Ceph File System common labels Jun 18, 2024
@ronen-fr ronen-fr changed the title Wip rf memmodel common: MemoryModel: performance improvements and API changes Jun 18, 2024
ronen-fr added 4 commits June 18, 2024 09:53
leave error reporting to the caller.
This change achieves two targets:
- no need for a context when creating the MemoryModel object; and
- (more importantly) the error messages are now reported in the context
  of the caller, and can be made to appear only once in the logs.

The existing client of the MemoryModel is modified to reflect the
changes to its API.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
Main points:
- using charconv as a faster alternative to strtoll functions;
- only parsing the addresses for relevant lines;
- lines ending with '[heap]' are OK

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
in the object itself

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
@ronen-fr ronen-fr marked this pull request as ready for review June 18, 2024 15:03
@ronen-fr ronen-fr added DNM and removed DNM labels Jun 19, 2024
@ronen-fr
Copy link
Contributor Author

jenkins test make check

@ronen-fr ronen-fr requested a review from a team June 21, 2024 10:22
@ronen-fr
Copy link
Contributor Author

ronen-fr commented Jul 7, 2024

@vshankar - can you review? thanks

@vshankar
Copy link
Contributor

vshankar commented Jul 8, 2024

@vshankar - can you review? thanks

Ofcourse 👍

(I will plan to have a look in the next few days)

Copy link
Contributor

@mchangir mchangir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a small query towards improving performance

Comment on lines +123 to +127
if (cmp_against(ln, "VmSize:", s.size) ||
cmp_against(ln, "VmRSS:", s.rss) || cmp_against(ln, "VmHWM:", s.hwm) ||
cmp_against(ln, "VmLib:", s.lib) ||
cmp_against(ln, "VmPeak:", s.peak) ||
cmp_against(ln, "VmData:", s.data)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be too much to push all required items in a hash table and test for the presence of the prefix of the current line in the hash table instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mchangir ,

Would it be too much to push all required items in a hash table and test for the presence of the prefix of the current line in the hash table instead ?

I do not see a way to do have better performance this way (I had originally measured multiple ideas I could think of). For example - note that we have sub-strings of at least two lengths here.

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDCache change look fine.

Copy link
Contributor

@mchangir mchangir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vshankar
Copy link
Contributor

This PR is under test in https://tracker.ceph.com/issues/67020.

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronen-fr ronen-fr merged commit 88f1230 into ceph:main Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants