Skip to content

Wrong unit in ResourceUsage.maxRSS - #19409

Closed
XeroAlpha wants to merge 1 commit into
oven-sh:mainfrom
XeroAlpha:main
Closed

Wrong unit in ResourceUsage.maxRSS#19409
XeroAlpha wants to merge 1 commit into
oven-sh:mainfrom
XeroAlpha:main

Conversation

@XeroAlpha

@XeroAlpha XeroAlpha commented May 1, 2025

Copy link
Copy Markdown

What does this PR do?

ResourceUsage.maxRSS is reported in kilobytes. See libuv api documentation.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

@RiskyMH RiskyMH added docs Improvements or additions to documentation types An issue with TypeScript types labels May 6, 2025
@robobun

robobun commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the report. This was accurate when it was opened: Subprocess.resourceUsage().maxRSS returned the raw ru_maxrss value, which is kilobytes on Linux (and PeakWorkingSetSize / 1024 on Windows) but bytes on macOS, so on Linux the documented unit was wrong.

It was fixed on the implementation side instead. Since #36087, src/spawn_sys/spawn_process.rs normalizes the value to bytes on every platform: ru_maxrss is multiplied by 1024 on non-Apple targets, and the Windows path stores PeakWorkingSetSize without dividing it. A quick check with a current build: for the same child process, process.resourceUsage().maxRSS inside the child reports 26964 (kilobytes, as in Node) and the parent's proc.resourceUsage().maxRSS reports 27611136, exactly 1024 times that. test/harness.ts also asserts the bytes unit now.

So the current docs (docs/runtime/child-process.mdx, which replaced docs/api/spawn.md in #24201) and the ResourceUsage.maxRSS JSDoc in packages/bun-types/bun.d.ts are correct as written, and changing them to kilobytes would now be wrong. Closing this one.

@robobun robobun closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation types An issue with TypeScript types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants