Skip to content

common: MemoryModel: performance improvements and API changes - #58115

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

ronen-fr merged 9 commits into
ceph:mainfrom
ronen-fr:wip-rf-memmodel

Conversation

@ronen-fr

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

Copy link
Copy Markdown
Contributor

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 <[email protected]>
(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 <[email protected]>
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 <[email protected]>
We're going to add this functionality to other components, simplify
this one first to match.

Signed-off-by: Samuel Just <[email protected]>
Signed-off-by: Shreekara <[email protected]>
(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 <[email protected]>
@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 <[email protected]>
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 <[email protected]>
in the object itself

Signed-off-by: Ronen Friedman <[email protected]>
@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
Copy Markdown
Contributor Author

jenkins test make check

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

ronen-fr commented Jul 7, 2024

Copy link
Copy Markdown
Contributor Author

@vshankar - can you review? thanks

@vshankar

vshankar commented Jul 8, 2024

Copy link
Copy Markdown
Contributor

@vshankar - can you review? thanks

Ofcourse 👍

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

@mchangir mchangir left a comment

Copy link
Copy Markdown
Contributor

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 thread src/common/MemoryModel.cc
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
Copy Markdown
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
Copy Markdown
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.

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MDCache change look fine.

@mchangir mchangir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@vshankar

Copy link
Copy Markdown
Contributor

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

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