Repository navigation
fix(host-monitor): exclude reclaimable cache from macOS memory usage - #2
Open
xt1990xt1990 wants to merge 1 commit into
Open
xt1990xt1990 wants to merge 1 commit into
xt1990xt1990 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS, host-monitor calculates used RAM as
os.totalmem() - os.freemem(), which includes reclaimable file-backed cache and overstates memory usage compared with Activity Monitor. On a 64 GiB Apple Silicon Mac, a local sample reported about 62.2 GiB used with the old calculation versus 43.7 GiB (68.3%) with this change.Read
vm_staton macOS and calculate anonymous pages minus purgeable pages, plus wired pages and the physical pages occupied by the compressor. Use the page size reported by the system to support both 4 KiB and 16 KiB pages. If collection fails, log the error and fall back to the existing OS counters.Reuse the memory reading from each sampling tick for RPC responses, keeping the displayed value consistent with history and avoiding an extra subprocess per client request. Document the macOS accounting and add focused regression tests.
Validation on Node.js 24.13.1:
npm run typecheckinplugins/host-monitorpassed against the latest main branch.node --test server/sampler.test.mjspassed all 3 tests: both page sizes, cache exclusion and physical compressor accounting, and incomplete output.