Skip to content

[gc-stats][windows] Exclude the runtime events ring from max RSS on Windows - #154

Open
ngorogiannis wants to merge 1 commit into
mac-rss-without-ringfrom
win-rss-without-ring
Open

ngorogiannis wants to merge 1 commit into
mac-rss-without-ringfrom
win-rss-without-ring

Conversation

@ngorogiannis

Copy link
Copy Markdown
Collaborator

The Windows arm of the exclusion the previous two commits added for
Linux and macOS.

The ring's mapping is found by walking the child's regions with
VirtualQueryEx and asking GetMappedFileNameW which file backs each
mapped one. A region carries no file identity here, only a name, so both
sides are resolved through an open handle:
the ring file's NT path comes from GetFinalPathNameByHandleW
with VOLUME_NAME_NT, which is the namespace GetMappedFileNameW answers
in. The extent then comes from the allocation base the view's regions
share, since VirtualProtect can split one MapViewOfFile across several.
The mapping never moves, so its range is cached.

Its resident share is counted with QueryWorkingSet, keeping the entries
that fall in that range. As on Linux those are the child's own pages,
the same ones GetProcessMemoryInfo returns the size of, so the ring's
pages are a subset of the working set by construction and the
subtraction is exact.

Windows reports WorkingSetSize and the poller takes the peak of the
difference, falling back to the kernel's exact PeakWorkingSetSize when
the ring cannot be attributed.

Unlike the other platforms the sample has to be discarded explicitly
once the child is gone. With its handle still open GetProcessMemoryInfo
keeps answering, returning the peak the ring was part of, while
everything that reads the address space starts failing, so that pair
would be recorded as a peak with the ring left in and would mark the
whole run as not having excluded it. GetExitCodeProcess is checked after
the numbers are read rather than before, since before it is exactly the
window that leaves open.

The path the FFI entry copies is no longer bounded by PATH_MAX, which is
260 on Windows and which a temp directory can exceed now that long paths
are supported.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@ngorogiannis
ngorogiannis added this pull request to stack #153 September 22, 2026 17:13
@ngorogiannis
ngorogiannis removed this pull request from stack #153 September 23, 2026 07:22
@ngorogiannis
ngorogiannis added this pull request to stack #156 September 23, 2026 07:25
@ngorogiannis
ngorogiannis force-pushed the win-rss-without-ring branch 3 times, most recently from 1295903 to 91b7c0d Compare November 10, 2026 18:27
@ngorogiannis
ngorogiannis marked this pull request as draft November 11, 2026 08:03
@ngorogiannis
ngorogiannis force-pushed the win-rss-without-ring branch 6 times, most recently from c3b4a62 to cabbb5d Compare November 13, 2026 17:27
…indows

The Windows arm of the exclusion the previous two commits added for
Linux and macOS.

The ring's mapping is found by walking the child's regions with
VirtualQueryEx and asking GetMappedFileNameW which file backs each
mapped one. A region carries no file identity here, only a name, so both
sides are resolved through an open handle:
the ring file's NT path comes from GetFinalPathNameByHandleW
with VOLUME_NAME_NT, which is the namespace GetMappedFileNameW answers
in. The extent then comes from the allocation base the view's regions
share, since VirtualProtect can split one MapViewOfFile across several.
The mapping never moves, so its range is cached.

Its resident share is counted with QueryWorkingSet, keeping the entries
that fall in that range. As on Linux those are the child's own pages,
the same ones GetProcessMemoryInfo returns the size of, so the ring's
pages are a subset of the working set by construction and the
subtraction is exact.

Windows reports WorkingSetSize and the poller takes the peak of the
difference, falling back to the kernel's exact PeakWorkingSetSize when
the ring cannot be attributed.

Unlike the other platforms the sample has to be discarded explicitly
once the child is gone. With its handle still open GetProcessMemoryInfo
keeps answering, returning the peak the ring was part of, while
everything that reads the address space starts failing, so that pair
would be recorded as a peak with the ring left in and would mark the
whole run as not having excluded it. GetExitCodeProcess is checked after
the numbers are read rather than before, since before it is exactly the
window that leaves open.

The path the FFI entry copies is no longer bounded by PATH_MAX, which is
260 on Windows and which a temp directory can exceed now that long paths
are supported.
@ngorogiannis
ngorogiannis marked this pull request as ready for review November 18, 2026 15:10
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.

1 participant