Repository navigation
feat(jsc): add byte-based heap allocation sampling - #2
Merged
Merged
Conversation
Record real GC-cell, auxiliary, and reported JS string storage allocations with allocating stacks and inverse-probability byte weights. Use existing free-list boundaries and a variable-size byte budget, reconcile weak owners before sweeping, and support independent major/minor collection inclusion. Add interpreter/JIT/large/string regressions and reuse the existing read-only engine CI artifact. The distribution and protocol semantics follow Node/V8; a matching Bun adapter and joint rebuild are required.
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.
OpenClaw's catalog performance consumers require byte-based allocation profiles that survive garbage collection. JSC's existing snapshots and CPU profiler cannot recover the allocation sites of objects already collected.
Add a VM-owned allocation sampler to
HeapProfiler. It limits the existing free-list range to route selected C++ and generated allocations through the slow path, preserving the disabled fast-path instructions. Exponential byte intervals and inverse inclusion-probability weights produce allocation-site trees and samples. Precise allocations, auxiliary growth and relocation, and deduplicated JS string backing allocations participate; sampled addresses are reconciled before sweeping without retaining objects. Stack capture is limited to 128 frames. Collection inclusion follows the actual major/minor collection type.The sampling contract follows Node/V8's implementation. Measurements cover JSC cells, newly reported string backing storage, and GC-managed auxiliary storage. Other native allocations and external buffers are outside this profile. This changes engine layouts and requires a joint Bun rebuild and the matching in-process inspector adapter.
Validation on one direct AWS Linux c7a.24xlarge using the unchanged WebKit lane recipe:
ABBA measurements use eight samples per arm, pinned to one CPU, at the default 32 KiB interval. Ratios compare allocation-loop medians; setup, final profile retrieval/GC, and serialization are outside the timed loops.
Both unmodified OpenClaw catalog consumers pass on snapshot
e9edda349faee43c13244cf3f4547fcbcb9c37fe; baseline Bun fails both at missingHeapProfiler.startSampling, and Node 24 passes both. The gateway observes about 1.17 MB/list and 524 CPU samples with both profilers active. The native ordinary/catalog walks observe about 403 MB/5.82 MB, each over 3,000 rows and 47 pages. Node's corresponding allocation estimates are 209 MB/10.20 MB; runtime allocation strategies and layouts differ, so these values are not expected to match numerically.The existing read-only engine PR workflow now runs the sampler regression across those tiers using the same Linux artifact as namespace qualification, before its existing paired Bun/fork gate. Artifact publication remains the separate coordinator-controlled workflow; this PR does not dispatch it. The matching Bun change stays draft until the batch-2 engine is published and pinned.