Skip to content

feat(track-memory-allocations): add total heap allocated bytes#24543

Closed
Boshen wants to merge 1 commit into
allocs-chunk-alloc-bytesfrom
allocs-snap-bytes
Closed

feat(track-memory-allocations): add total heap allocated bytes#24543
Boshen wants to merge 1 commit into
allocs-chunk-alloc-bytesfrom
allocs-snap-bytes

Conversation

@Boshen

@Boshen Boshen commented Jul 15, 2026

Copy link
Copy Markdown
Member

Third of three PRs splitting the byte-metrics work (stacked on the chunk-alloc-bytes PR).

Adds a sys alloc bytes value to each per-file block: total bytes requested from the system allocator during the stage. Each realloc counts its full new size. Arena chunk allocations are excluded using the chunk byte totals from the previous PR, mirroring the existing exclusion of chunk counts from sys allocs.

checker.ts
  file size: 2.92 MB
  sys allocs: 1818
  sys reallocs: 10
  sys alloc bytes: 69339 (69.34 kB)
  arena allocs: 264366
  arena reallocs: 22860
  arena size: 12985208 (12.99 MB)

Byte-value lines record Linux x64 (CI) values per the policy established in the arena-size PR; the cross-platform behavior is documented in the source next to the byte counter. The first CI run of the combined change confirmed only byte lines differ between platforms — counts are identical.

🤖 Generated with Claude Code

Boshen commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the A-allocator Area - Allocator label Jul 15, 2026
@Boshen
Boshen force-pushed the allocs-snap-bytes branch from 1614ca0 to 440629a Compare July 15, 2026 09:15
@Boshen Boshen changed the title feat(track-memory-allocations): add total heap allocated bytes and final arena size feat(track-memory-allocations): add total heap allocated bytes and arena size Jul 15, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing allocs-snap-bytes (f83d4e0) with main (246b426)2

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on allocs-chunk-alloc-bytes (87cc31d) during the generation of this report, so main (246b426) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel

overlookmotel commented Jul 15, 2026

Copy link
Copy Markdown
Member

@camchenry tried this before, but problem was that the numbers aren't consistent across runs.

I narrowed down at least one source of the problem: #23728 (comment)


As it happens, I was talking to Claude about this last week.

The indeterminism is likely caused by Address Space Layout Randomization (ASLR).

On Linux, you can disable ASLR with setarch $(uname -m) -R ./binary, so we could probably get consistent numbers in CI. But Mac has no option to disable ASLR, so it wouldn't work on local dev machines.

One way to tackle it cross-platform is to shim the system allocator. Reserve a large chunk of address space from system at a fixed address with mmap, then pass that to Mimalloc to use as its heap. That would likely solve the problem (and also likely remove a lot of variance from our benchmarks), but it's not a trivial thing to implement.

@overlookmotel

overlookmotel commented Jul 15, 2026

Copy link
Copy Markdown
Member

Arena bytes should be consistent across platforms and runs for parser and semantic - I believe they're purely deterministic. But transformer introduces indeterminism, which also then affects minifier (since it has to run after transform). Not sure about formatter.

Sys alloc bytes may not be stable on any component (even parser).

@graphite-app
graphite-app Bot changed the base branch from allocs-snap-vertical to graphite-base/24543 July 15, 2026 12:20
@graphite-app
graphite-app Bot force-pushed the graphite-base/24543 branch from 00c509d to 31281d3 Compare July 15, 2026 12:24
@graphite-app
graphite-app Bot force-pushed the allocs-snap-bytes branch from fa30393 to 69068b0 Compare July 15, 2026 12:24
@graphite-app
graphite-app Bot changed the base branch from graphite-base/24543 to main July 15, 2026 12:25
@graphite-app
graphite-app Bot force-pushed the allocs-snap-bytes branch from 69068b0 to 6573f83 Compare July 15, 2026 12:25
@Boshen
Boshen force-pushed the allocs-snap-bytes branch 2 times, most recently from 906b58c to f83d4e0 Compare July 15, 2026 12:36
@Boshen Boshen changed the title feat(track-memory-allocations): add total heap allocated bytes and arena size feat(track-memory-allocations): add total heap allocated bytes Jul 15, 2026
@Boshen
Boshen changed the base branch from main to allocs-chunk-alloc-bytes July 15, 2026 12:37
@graphite-app
graphite-app Bot force-pushed the allocs-chunk-alloc-bytes branch 2 times, most recently from 05eda40 to f0a9bb7 Compare July 15, 2026 13:26
Adds a `sys alloc bytes` value to each per-file block in the allocation
snapshots: total bytes requested from the system allocator during the
stage. Each `realloc` counts its full new size. Arena chunk allocations are
excluded using the byte totals from the previous commit, mirroring the
existing exclusion of chunk counts from `sys allocs`.

Byte-value lines record Linux x64 (CI) values, per the policy established
for `arena size`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@graphite-app
graphite-app Bot force-pushed the allocs-snap-bytes branch from f83d4e0 to 073e5a0 Compare July 15, 2026 13:26
@Boshen Boshen closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants