fix(process): implement process.memoryUsage.rss() fast-path call (#1395) - #1466
Merged
Conversation
Node exposes `process.memoryUsage.rss()` as a fast-path that returns
just the resident-set-size as a number, avoiding the
`{ rss, heapTotal, heapUsed, external, arrayBuffers }` object allocation
of `process.memoryUsage()`. Perry didn't have it: the call hit the
generic property-call path against `process.memoryUsage` (a 0.0 sentinel
when read as a value), so it threw `TypeError: (number).rss is not a
function`.
Add `try_process_memory_usage_rss` to the nested-namespace dispatch
table (mirroring `process.hrtime.bigint()`). Lowers
`process.memoryUsage.rss()` to `(process.memoryUsage()).rss` — same
numeric value Node's fast path returns. We pay the object-allocation
cost the fast path was meant to avoid, but parity is restored and the
call form works in user code.
The bare `typeof process.memoryUsage.rss` value-read is still tracked
separately (same class as the namespace-method-typeof gap from #1320 /
#1343 — out of scope here).
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.
Summary
process.memoryUsage.rss()fast path was missing in Perry — calling it threwTypeError: (number).rss is not a functionbecauseprocess.memoryUsageread as a value gives a 0.0 sentinel.process.hrtime.bigint()one: lowersprocess.memoryUsage.rss()to(process.memoryUsage()).rss. Same numeric result Node's fast path returns.Closes #1395.
Notes
typeof process.memoryUsage.rssvalue-read still returns"undefined"in Perry (Node returns"function"). That's the same namespace-method-typeof class as the#1320/#1343work — tracked separately, not in scope here.process.hrtime.bigint()andprocess.memoryUsage()paths unchanged.Test plan
process.memoryUsage.rss()returns a positive number (matches Node parity fortypeof+> 0)process.memoryUsage().rssand.heapUsedstill workprocess.hrtime.bigint()still works (the sibling nested-namespace arm)cargo fmt --all -- --checkcargo test -p perry-hir