feat: add fileBacked and purgeable fields to process.getSystemMemoryInfo() for macOS#47628
Conversation
MarshallOfSound
left a comment
There was a problem hiding this comment.
I'd prefer to expose new numbers, not change existing ones as people will have existing metrics that we'd be breaking.
Also cc @felixrieseberg because I know you've stared at how memory metrics work a lot in the past, any thoughts here
|
@MarshallOfSound I agree with you. I have changed the code. |
There was a problem hiding this comment.
Thanks! Could you please also adjust the docs?
Line 206 in 655037f
Could you please also update the PR title and release notes to reflect your most recent change?
getSystemMemoryInfo()
|
@nikwen |
getSystemMemoryInfo()getSystemMemoryInfo()
| dict.Set("free", free); | ||
|
|
||
| #if BUILDFLAG(IS_MAC) | ||
| dict.Set("cached", mem_info.file_backed); |
There was a problem hiding this comment.
Should this be named fileBacked instead? I see another property named cached and want to make sure this won't conflict in the future.
https://source.chromium.org/chromium/chromium/src/+/main:base/process/process_metrics.h;l=365;drc=17b4c42cfb3512836655464b0d41d319e819c0b6
There was a problem hiding this comment.
Yes, this field name might be better, I have considered using this name before.
Originally I wanted to make the name of this field consistent with what is displayed in the Activity Monitor.
itsananderson
left a comment
There was a problem hiding this comment.
A couple suggestions for tweaking the docs wording
b28f1be to
37ef641
Compare
|
@codebytere |
nikwen
left a comment
There was a problem hiding this comment.
Thanks for adding docs! The code looks fine to me.
- Could you please update the release notes in the PR description?
- Could you please use a more descriptive title for the PR? This will be the commit message once the PR is merged.
getSystemMemoryInfo()getSystemMemoryInfo() for macOS.
getSystemMemoryInfo() for macOS.|
@nikwen |
|
Thanks for the changes! Please take a look at the commit message guidelines. The "add" in the PR title should be present tense and lowercase. Additionally, it's always great to wrap any function or field names in backticks to render them as code, e.g., |
Co-authored-by: Will Anderson <will@itsananderson.com>
b68f43c to
e0327c1
Compare
|
Hi @codebytere |
|
Release Notes Persisted
|
|
I was unable to backport this PR to "38-x-y" cleanly; |
|
I was unable to backport this PR to "37-x-y" cleanly; |
…moryInfo()` for macOS (electron#47628) * fix: Optimize the value of memory.free in the return data of getSystemMemoryInfo(). * fix: Improve the value of memory in the return data of getSystemMemoryInfo(). * fix: complete API doc. * Update docs/api/process.md Co-authored-by: Will Anderson <will@itsananderson.com> * fix: update name to fileBacked. * fix: fix with code conflict --------- Co-authored-by: Will Anderson <will@itsananderson.com>
Description of Change
On macOS, the free value in the memory data obtained from process.getSystemMemoryInfo() differs significantly from the value displayed in Activity Monitor.
The reason is that the free value is calculated from free_count in vm_statistics64_data_t.
The relevant code is located in: https://source.chromium.org/chromium/chromium/src/+/main:base/process/process_metrics_apple.mm;drc=bcbe20a25707502c2ba340cfd4dbe8cd015fa864;l=255
To handle this issue, I propose two approaches:
Calculate and return the adjusted value directly in electron_bindings.cc while maintaining the original data format.
Add two new fields: cached and purgeable, to provide more granular memory usage details.
Checklist
npm testpassesRelease Notes
Notes: Added
fileBackedandpurgeablefields toprocess.getSystemMemoryInfo()for macOS.