Skip to content

feat(track-memory-allocations): track deallocations, peak heap growth, arena growth, and all-arena totals#24550

Closed
Boshen wants to merge 1 commit into
allocs-snap-bytesfrom
allocs-snap-more-metrics
Closed

feat(track-memory-allocations): track deallocations, peak heap growth, arena growth, and all-arena totals#24550
Boshen wants to merge 1 commit into
allocs-snap-bytesfrom
allocs-snap-more-metrics

Conversation

@Boshen

@Boshen Boshen commented Jul 15, 2026

Copy link
Copy Markdown
Member

Stacked on #24543. Adds six values to each per-file block, extending the snapshots with deallocation, footprint, and attribution metrics:

checker.ts                          (semantic stage)
  file size: 2.92 MB
  sys allocs: 46
  sys reallocs: 0
  sys deallocs: 46
  sys alloc bytes: 3866958 (3.87 MB)
  sys dealloc bytes: 3866958 (3.87 MB)
  peak heap growth: 7542870 (7.54 MB)
  arena allocs: 0
  arena reallocs: 0
  total arena allocs: 37851
  total arena reallocs: 22022
  arena growth: 0 (0 B)
  arena size: 12985152 (12.99 MB)
  • sys deallocs / sys dealloc bytes — deallocations via the system allocator, with arena chunk deallocations excluded (mirroring the alloc-side exclusion). Each realloc counts its old size as freed, so sys alloc bytes − sys dealloc bytes is the net bytes a stage retains. The semantic block above shows its value: semantic's 3.87 MB of SoA tables are pure churn — allocated and fully freed within the stage.
  • peak heap growth — the largest rise of live heap bytes above the stage's starting level at any moment during the stage. Catches transient balloons the cumulative counters can't see (semantic's true transient footprint is 7.54 MB, previously invisible). Arena chunks are included here — it's a footprint number — so values move in chunk-sized steps when transient arenas are created.
  • total arena allocs / total arena reallocs — allocations in ALL arenas via new global counters. Fixes a blind spot: short-lived arenas dropped inside a stage (e.g. the arena backing semantic's Scoping) had per-arena stats that died with them — the semantic stage claimed arena allocs: 0 while building an entire arena (actual: 37851).
  • arena growth — used-bytes delta of the measured Allocator, attributing arena consumption to the stage that caused it; the existing arena size gauge stays as the cumulative view (parser: growth == size, built from empty).

oxc_allocator's feature-gated tracking now also records chunk deallocation count/bytes (global_chunk_deallocation_stats) and global all-arena alloc/realloc counts (global_arena_allocation_stats).

Byte-value lines follow the established policy from #24543: snapshots record Linux x64 (CI) values. All count lines — including the new sys deallocs and total arena lines — are expected to be platform-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.

@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-more-metrics (7cead98) with allocs-snap-bytes (f83d4e0)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-snap-bytes (073e5a0) during the generation of this report, so 3035510 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app
graphite-app Bot force-pushed the allocs-snap-bytes branch 2 times, most recently from 69068b0 to 6573f83 Compare July 15, 2026 12:25
@graphite-app
graphite-app Bot force-pushed the allocs-snap-more-metrics branch from 9e4f596 to 6b3deac Compare July 15, 2026 12:25
@Boshen
Boshen force-pushed the allocs-snap-more-metrics branch from 6b3deac to 80f0091 Compare July 15, 2026 12:33
@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 force-pushed the allocs-snap-more-metrics branch from 80f0091 to 9379170 Compare July 15, 2026 12:36
@Boshen
Boshen changed the base branch from allocs-snap-bytes to graphite-base/24550 July 15, 2026 13:04
@Boshen
Boshen changed the base branch from graphite-base/24550 to allocs-snap-bytes July 15, 2026 13:05
@graphite-app
graphite-app Bot force-pushed the allocs-snap-bytes branch from f83d4e0 to 073e5a0 Compare July 15, 2026 13:26
…, arena growth, and all-arena totals

Adds six values to each per-file block in the allocation snapshots:

- `sys deallocs` / `sys dealloc bytes`: deallocations made via the system
  allocator, excluding arena chunk deallocations (mirroring the alloc-side
  chunk exclusion). Each `realloc` counts its old size as freed, so
  `sys alloc bytes - sys dealloc bytes` is the net bytes a stage retains.
  Distinguishes churn (allocated and freed within the stage) from retained
  memory.
- `peak heap growth`: the largest rise of live system-allocator bytes above
  the stage's starting level, at any moment during the stage. Catches
  transient balloons that cumulative counters cannot see. Arena chunks are
  included — this is a footprint number — so values move in chunk-sized
  steps when transient arenas are created.
- `total arena allocs` / `total arena reallocs`: allocations in ALL arenas,
  tracked by global counters. Short-lived arenas dropped inside a stage
  (e.g. the arena backing oxc_semantic's Scoping) were previously invisible:
  the semantic stage showed `arena allocs: 0` while building a whole arena.
- `arena growth`: used-bytes delta of the measured Allocator's arena,
  attributing arena consumption to the stage that caused it (the existing
  `arena size` gauge is cumulative across stages).

oxc_allocator's tracking (feature-gated) now records chunk deallocation
count/bytes and global all-arena alloc/realloc counts.

Byte-value lines follow the established policy: snapshots record Linux x64
(CI) values; counts are identical on all platforms.

🤖 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-more-metrics branch from 9379170 to 7cead98 Compare July 15, 2026 13:27
@Boshen Boshen closed this Jul 15, 2026
@Boshen
Boshen deleted the allocs-snap-more-metrics branch July 15, 2026 14:08
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.

1 participant