Skip to content

fix(process): implement process.memoryUsage.rss() fast-path call (#1395) - #1466

Merged
proggeramlug merged 1 commit into
mainfrom
worktree-fix-1395
May 23, 2026
Merged

fix(process): implement process.memoryUsage.rss() fast-path call (#1395)#1466
proggeramlug merged 1 commit into
mainfrom
worktree-fix-1395

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

  • Node's process.memoryUsage.rss() fast path was missing in Perry — calling it threw TypeError: (number).rss is not a function because process.memoryUsage read as a value gives a 0.0 sentinel.
  • Adds a nested-namespace lowering arm next to the existing process.hrtime.bigint() one: lowers process.memoryUsage.rss() to (process.memoryUsage()).rss. Same numeric result Node's fast path returns.

Closes #1395.

Notes

  • The bare typeof process.memoryUsage.rss value-read still returns "undefined" in Perry (Node returns "function"). That's the same namespace-method-typeof class as the #1320 / #1343 work — tracked separately, not in scope here.
  • Existing process.hrtime.bigint() and process.memoryUsage() paths unchanged.

Test plan

  • process.memoryUsage.rss() returns a positive number (matches Node parity for typeof + > 0)
  • regression: process.memoryUsage().rss and .heapUsed still work
  • regression: process.hrtime.bigint() still works (the sibling nested-namespace arm)
  • cargo fmt --all -- --check
  • cargo test -p perry-hir

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).
@proggeramlug
proggeramlug merged commit f46c4c3 into main May 23, 2026
9 checks passed
@proggeramlug
proggeramlug deleted the worktree-fix-1395 branch May 23, 2026 07:19
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.

node:process — implement process.memoryUsage.rss()

1 participant