Skip to content

perf: use the faster api to collect rss#742

Merged
jdmarshall merged 3 commits into
prometheus:mainfrom
chidam333:master
Jun 29, 2026
Merged

perf: use the faster api to collect rss#742
jdmarshall merged 3 commits into
prometheus:mainfrom
chidam333:master

Conversation

@chidam333

Copy link
Copy Markdown
Contributor

https://nodejs.org/api/process.html#processmemoryusagerss

i think we can use the faster api to collect rss

Copilot AI review requested due to automatic review settings March 15, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates default RSS collection on non-Linux platforms to use Node’s faster RSS-only API, reducing overhead during metrics collection.

Changes:

  • Switch non-Linux process_resident_memory_bytes collection from process.memoryUsage() to process.memoryUsage.rss().
  • Add a new safeRss() helper to safely read RSS with a try/catch wrapper.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/metrics/osMemoryHeap.js Uses safeRss() to collect RSS for the non-Linux variant of process_resident_memory_bytes.
lib/metrics/helpers/safeRss.js Introduces a helper that calls process.memoryUsage.rss() and swallows platform/runtime errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread lib/metrics/helpers/safeRss.js
Comment thread lib/metrics/osMemoryHeap.js
try {
return process.memoryUsage.rss();
} catch {
return;

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.

I'd like to use debug for this in the future but for now we only use it for the benchmarks, so I'm not going to force the issue here, despite the silent return being kind of smelly.

@jdmarshall

Copy link
Copy Markdown
Contributor

@chidam333 Something is glitching with github actions and I'm unsure why I can't make this build. You might need to push a do-nothing change.

@chidam333

Copy link
Copy Markdown
Contributor Author

hello @jdmarshall i added a dummy commit, is the issue resolved ?

@chidam333

Copy link
Copy Markdown
Contributor Author

DCO check happened now? was that the issue ?

@jdmarshall

Copy link
Copy Markdown
Contributor

Not entirely sure yet. There’s a handful that are in each state. I submitted one without DCO and I’m fairly sure the builds ran anyway.

@jdmarshall

jdmarshall commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Can you update the change list?

also, do we have a benchmark for this? Would be good to identify or write one for “perf” changes.

@chidam333

chidam333 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author
image image image

I am seeing 30-40% improvement. (added changelog)

chidam333#1 <- code i used for benchmarking.

@chidam333

Copy link
Copy Markdown
Contributor Author

@jdmarshall i had to rebase for signing, but i can see that it shows a bunch of unrelated
diffs in my pr in github, I verified that those changes are already in main, do you still want me to cherry pick those changes ?

image

rss.patch

added patch file for confirmation

@jdmarshall

Copy link
Copy Markdown
Contributor

That's... weird for a rebase. I'm going to say no specifically because of the workflow changes.

I'd try resetting your branch to HEAD and cherry-picking your changes back on top, please.

Signed-off-by: chidam333 <chidam.sync@gmail.com>
Signed-off-by: chidam333 <chidam.sync@gmail.com>
Signed-off-by: chidam333 <chidam.sync@gmail.com>
@chidam333

Copy link
Copy Markdown
Contributor Author

done, thank you

@jdmarshall jdmarshall merged commit 7332f59 into prometheus:main Jun 29, 2026
14 checks passed
@chidam333

Copy link
Copy Markdown
Contributor Author

thank you :)

also faceoff looks great ❤️

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.

3 participants