Skip to content

Add smaps and proc_status memory usage services - #754

Open
gaber wants to merge 1 commit into
llnl:masterfrom
gaber:gaber/smaps
Open

Add smaps and proc_status memory usage services#754
gaber wants to merge 1 commit into
llnl:masterfrom
gaber:gaber/smaps

Conversation

@gaber

@gaber gaber commented Aug 27, 2026

Copy link
Copy Markdown

For context: I've been looking for ways to help applications reduce memory usage. Sometimes that means helping teams find opportunities to make greater use of shared memory. So I went looking for ways to quantify that benefit, which led me to reading proportional set size (PSS) from /proc/self/smaps_rollup.

Add two new services under src/services/memusage/:

  • smaps: records RSS, PSS, and shared/private clean/dirty memory from /proc/self/smaps_rollup.
  • proc_status: records virtual memory, RSS, swap, and hugetlb usage from /proc/self/status, resetting the kernel's RSS high-water mark via /proc/self/clear_refs after each snapshot (which can help uncover regions with high but short-lived usage).

Both implementations drew heavy inspiration from the existing memstat service (src/services/memusage/MemStatService.cpp), and since these new services also each read memory usage info from a file in /proc I put them in that same memusage subdirectory as a starting point. Happy to move, rename, refactor anything you want changed!

Also:

  • formatted both new files with clang-format;
  • added a section describing each service in doc/sphinx/services.rst;
  • and added a test for each service in test/ci_app_tests/test_linux_services.py.

Add two new services under src/services/memusage/:

* smaps: records RSS, PSS, and shared/private clean/dirty memory
  from /proc/self/smaps_rollup.
* proc_status: records virtual memory, RSS, swap, and hugetlb usage
  from /proc/self/status, resetting the kernel's RSS high-water mark
  via /proc/self/clear_refs after each snapshot.

Register both services in CMakeLists.txt, add CI tests in
test_linux_services.py, and document both services in
doc/sphinx/services.rst.
@daboehme

Copy link
Copy Markdown
Member

Nice, thanks @gaber!

This is pretty much how I would have written. I'm happy to merge it.

One more thing we can do is add some ConfigManager option specs to builtin_gotcha_option_specs in src/caliper/controllers/controllers.cpp so we can use these services in built-in recipes like runtime-report. This can be added later though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants