Skip to content

[linux] Exclude the ring from max RSS - #151

Open
ngorogiannis wants to merge 1 commit into
mainfrom
linux-rss-without-ring
Open

ngorogiannis wants to merge 1 commit into
mainfrom
linux-rss-without-ring

Conversation

@ngorogiannis

Copy link
Copy Markdown
Collaborator

The ring is mmap'd into the traced process, so its resident pages were
counted in max_rss_kb: a 512MB ring against a 3MB live set reported
106MB (#104).

gc-stats now reports the traced program's RSS minus the ring RSS. Where
the ring cannot be attributed, the output says so.

The Linux arm locates the ring's mapping in /proc//maps and counts
its resident pages from /proc//pagemap. Those are the same page
tables VmRSS is drawn from, so the ring's pages are a subset of the RSS
by construction and the subtraction is exact. The address range is found
once and remembered, since the mapping never moves. The walk runs with
the runtime lock released, so the poller domain cannot stall the domain
draining the ring.

Because only the current RSS can be decomposed, Linux now reports VmRSS
and the poller takes the peak of the difference; it falls back to the
kernel's exact VmHWM when the ring cannot be attributed. The poller
ignores samples whose RSS reads as zero (in case the process exited
before olly checks) so they no longer mark an otherwise sound run's peak
as untrustworthy.

The json output is now version 3 and carries max_rss_excludes_ring,
false wherever the ring could not be attributed. The field is required,
so a version 2 document no longer decodes; validate-gc-stats accepts
1 <= version <= 3 and, in jsonlines mode, still skips the lines whose
version is not the current one.

Also splits the C stub so that each platform arm supplies only
platform_sample and the FFI entry point exists once, making a detached

macOS and FreeBSD still report the RSS with the ring included, and are
left as further work.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@ngorogiannis
ngorogiannis added this pull request to stack #153 September 22, 2026 10:46
@ngorogiannis
ngorogiannis removed this pull request from stack #153 September 23, 2026 07:22
@ngorogiannis
ngorogiannis changed the base branch from main to win-channel-caching September 23, 2026 07:25
@ngorogiannis
ngorogiannis added this pull request to stack #156 September 23, 2026 07:25
Base automatically changed from win-channel-caching to main September 30, 2026 07:53
@ngorogiannis
ngorogiannis force-pushed the linux-rss-without-ring branch 3 times, most recently from 17062a7 to 38c54f2 Compare September 30, 2026 07:55
@ngorogiannis
ngorogiannis force-pushed the linux-rss-without-ring branch 3 times, most recently from 09e4927 to 70211a2 Compare November 10, 2026 18:27
@ngorogiannis
ngorogiannis marked this pull request as draft November 11, 2026 08:03
@ngorogiannis
ngorogiannis force-pushed the linux-rss-without-ring branch 4 times, most recently from d5dc5fe to 5108534 Compare November 13, 2026 14:14
The ring is mmap'd into the traced process, so its resident pages were
counted in max_rss_kb: a 512MB ring against a 3MB live set reported
106MB (#104).

gc-stats now reports the traced program's RSS minus the ring RSS. Where
the ring cannot be attributed, the output says so.

The Linux arm locates the ring's mapping in /proc/<pid>/maps and counts
its resident pages from /proc/<pid>/pagemap. Those are the same page
tables VmRSS is drawn from, so the ring's pages are a subset of the RSS
by construction and the subtraction is exact. The address range is found
once and remembered, since the mapping never moves. The walk runs with
the runtime lock released, so the poller domain cannot stall the domain
draining the ring.

Because only the current RSS can be decomposed, Linux now reports VmRSS
and the poller takes the peak of the difference; it falls back to the
kernel's exact VmHWM when the ring cannot be attributed. The poller
ignores samples whose RSS reads as zero (in case the process exited
before olly checks) so they no longer mark an otherwise sound run's peak
as untrustworthy.

The json output is now version 3 and carries max_rss_excludes_ring,
false wherever the ring could not be attributed. The field is required,
so a version 2 document no longer decodes; validate-gc-stats accepts
1 <= version <= 3 and, in jsonlines mode, still skips the lines whose
version is not the current one.

Also splits the C stub so that each platform arm supplies only
platform_sample and the FFI entry point exists once, making a detached

macOS and FreeBSD still report the RSS with the ring included, and are
left as further work.
@ngorogiannis
ngorogiannis force-pushed the linux-rss-without-ring branch from 5108534 to 76d3e12 Compare November 13, 2026 14:16
@ngorogiannis
ngorogiannis marked this pull request as ready for review November 13, 2026 14:16

@edwintorok edwintorok left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks good

Comment thread lib/olly_gc_stats/json.ml Resolved
Comment thread lib/olly_common/cli.ml Resolved
Comment thread lib/olly_common/max_rss_stubs.c Resolved
Comment thread lib/olly_common/max_rss_stubs.c Resolved
Comment thread lib/olly_common/max_rss_stubs.c Resolved
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