cli: --heap-prof node parity, and fix absolute profile paths panicking (+2 tests) - #34842
Merged
cirospaciari merged 2 commits intoJul 20, 2026
Merged
Conversation
--heap-prof-name/-dir/-interval without --heap-prof now exit 9 with node's
"<argv0>: <flag> must be used with --heap-prof" instead of warning and
continuing; --heap-prof-interval was previously not registered at all, so
`bun --heap-prof-interval 128 x.js` parsed 128 as the script. An interval
equal to node's default (512 KiB) is a noop without --heap-prof, like node.
--heap-prof now writes node's V8 sampling-heap-profile JSON
({"head": {...}, "samples": [...]}) under node's filename format
Heap.<yyyymmdd>.<hhmmss>.<pid>.<tid>.<seq>.heapprofile in local time (the old
name also hit the same non-wall-clock Timespec bug the CPU side fixed).
JavaScriptCore has no allocation-site sampler, so the profile reports the
real live-heap size on the (root) frame with no per-function attribution;
the full .heapsnapshot remains available via v8.writeHeapSnapshot() and
Bun.generateHeapSnapshot("v8"). The markdown format (--heap-prof-md) is
unchanged. Heap profiles also flush on a self-directed fatal signal via
process.kill, sharing the CPU profiler's hook.
Writing to an absolute --heap-prof-dir or --heap-prof-name (and an absolute
--cpu-prof-name) previously hit a debug assertion in AutoAbsPath::append;
both writers now use resolve-style join.
Adds two upstream Node v26.3.0 tests, verbatim. The other nine
test-heap-prof-* files assert a runAllocation call frame inside the profile
tree (or per-worker profiles), which requires allocation-stack sampling JSC
does not provide, so they are not vendored.
Collaborator
|
Updated 1:07 PM PT - Jul 20th, 2026
❌ @autofix-ci[bot], your commit ac412e4 has 3 failures in
🧪 To try this PR locally: bunx bun-pr 34842That installs a local version of the PR into your bun-34842 --bun |
Contributor
|
Found 2 issues this PR may fix:
🤖 Generated with Claude Code |
Contributor
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
cirospaciari
merged commit Jul 20, 2026
2a0e723
into
claude/callback-throw-uncaught
72 of 76 checks passed
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.
Extends the cpu-prof CLI parity on the base branch to
--heap-prof, and fixes a real crash. Stacked on #34660.The honest ceiling, established first
JSC has no allocation-sampling profiler.
HeapProfiler.hin the prebuilt WebKit is snapshots-only,SamplingProfiler.his CPU stack sampling, andnm libJavaScriptCore.aexports no sampling-heap symbols. A generated bun heap snapshot carriestrace_function_infos: []— zero allocation-site data exists anywhere.Node's
.heapprofile(measured on the v26.3.0 binary) has real V8-attributed call frames even for-e '0', and 9 of the 11 upstream tests assert arunAllocationframe in the tree. That cannot be produced honestly, so those 9 stay unconverted — the profile bun writes reports the real live-heap size on the(root)frame with no synthetic frames, which is V8's own shape for unattributed allocations.What's here
--heap-prof-intervalregistered as value-taking (previously128parsed as the script name — verified); name/dir/interval without--heap-profexit 9 with node's exact message, mirroring the base branch's cpu-prof block; default-interval noop like node.Heap.<yyyymmdd>.<hhmmss>.<pid>.0.<seq>.heapprofilefilename in local time — the old name had the same non-wall-clockTimespecbug the CPU side fixed (it producedHeap.1540804227270…).process.exitand self-directed fatal signals via the hook the cpu profiler already uses (Bun__writeCPUProfileBeforeSelfKill→Bun__writeProfilesBeforeSelfKill)..heapsnapshotcapability preserved viav8.writeHeapSnapshot/Bun.generateHeapSnapshot("v8")(smoke-tested).Real crash fixed
An absolute
--heap-prof-dir,--heap-prof-name— or--cpu-prof-name, already shipped on the base branch — hitassertion failed: !is_input_absoluteinAutoAbsPath::appendand died with exit 134. Both writers now join resolve-style. Verified: absolute paths write the profile and exit 0.Tests
test-heap-prof-basicandtest-heap-prof-invalid-args, verbatim, node-ceiling-checked, 3× green, failing on system bun as control, tamper-checked. The 9 unconvertible files fail only onverifyFrames('runAllocation')— exit codes, dir creation, and SIGINT/exit-55 flush all work.Regressions:
cpu-prof.test.ts9/9, the base branch's 6 vendored cpu-prof tests green,test/js/node/processunchanged, v8 heap-snapshot smoke OK.cargo checkclean on windows-msvc and linux-gnu targets. Bun-sidetest/cli/heap-prof.test.tsrewritten for the new behavior (13 pass).