Skip to content

Read Linux RSS directly from procfs - #92

Open
OskarEichler wants to merge 2 commits into
rdp:masterfrom
OskarEichler:codex/linux-rss-procfs
Open

OskarEichler wants to merge 2 commits into
rdp:masterfrom
OskarEichler:codex/linux-rss-procfs

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

OS.rss_bytes currently starts ps for every POSIX call even though Linux exposes the current process resident set in /proc/self/status.

This parses VmRSS (reported in kB) directly on Linux and preserves the existing ps path when procfs is unreadable or lacks the field.

Verification

  • added a focused procfs regression
  • Ruby 4.0.6: 37 examples, 0 failures
  • combined candidates: 42 examples, 0 failures on Ruby 4.0.6 and 3.2.11
  • syntax and diff checks pass

macOS/BSD and Windows/JRuby behavior is unchanged.

Prefer the current process status file over spawning ps while retaining the existing POSIX fallback.
@OskarEichler

Copy link
Copy Markdown
Author

A second pass found a small TOCTOU edge case between File.readable? and File.foreach: if procfs disappears or becomes unreadable in between, RSS collection would raise instead of preserving the existing ps fallback. I added a narrow SystemCallError fallback and regression coverage. The focused specs pass (23 examples).

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