Skip to content

refactor(allocator): replace ChunkFooter::is_empty with free function#21772

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/04-26-refactor_allocator_replace_chunkfooter_is_empty_with_free_function
Apr 26, 2026
Merged

refactor(allocator): replace ChunkFooter::is_empty with free function#21772
graphite-app[bot] merged 1 commit intomainfrom
om/04-26-refactor_allocator_replace_chunkfooter_is_empty_with_free_function

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 26, 2026

Remove ChunkFooter::is_empty method and add an is_empty_footer free function instead. This is beneficial as it removes the need for unsafe pointer to reference conversions.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 26, 2026


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
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 26, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/04-26-refactor_allocator_replace_chunkfooter_is_empty_with_free_function (f8422e2) with om/04-25-perf_allocator_allocator_used_bytes_do_not_use_chunk_iterator (7896bd0)

Open in CodSpeed

Footnotes

  1. 3 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.

@overlookmotel overlookmotel marked this pull request as ready for review April 26, 2026 11:57
Copilot AI review requested due to automatic review settings April 26, 2026 11:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the arena allocator’s “empty chunk footer” sentinel check by removing the private ChunkFooter::is_empty method and introducing a free function that checks sentinel-ness via pointer equality, avoiding reference conversions solely for comparison.

Changes:

  • Removed ChunkFooter::is_empty(&self) and added is_empty_footer(NonNull<ChunkFooter>) in arena/mod.rs.
  • Updated chunk-walking/reset/drop/allocation code paths to use is_empty_footer instead of deref + method calls.
  • Reduced unnecessary NonNull::as_ref() usage in iterator/byte-counting logic when only sentinel checks are needed.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
crates/oxc_allocator/src/arena/mod.rs Replaces the ChunkFooter::is_empty method with the is_empty_footer free function based on pointer equality to the canonical sentinel.
crates/oxc_allocator/src/arena/drop.rs Updates reset, chunk list deallocation, and related assertions to use is_empty_footer.
crates/oxc_allocator/src/arena/chunks.rs Refactors chunk iteration and used_bytes/allocated_bytes logic to check sentinel via is_empty_footer before dereferencing.
crates/oxc_allocator/src/arena/alloc_impl.rs Uses is_empty_footer to avoid touching the static empty footer’s interior mutability (prevents potential data race) without needing a ref conversion to check emptiness.

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 26, 2026

Merge activity

…on (#21772)

Remove `ChunkFooter::is_empty` method and add an `is_empty_footer` free function instead. This is beneficial as it removes the need for unsafe pointer to reference conversions.
@graphite-app graphite-app Bot force-pushed the om/04-25-perf_allocator_allocator_used_bytes_do_not_use_chunk_iterator branch from efe454e to 7896bd0 Compare April 26, 2026 21:48
@graphite-app graphite-app Bot force-pushed the om/04-26-refactor_allocator_replace_chunkfooter_is_empty_with_free_function branch from b8065a7 to f8422e2 Compare April 26, 2026 21:49
Base automatically changed from om/04-25-perf_allocator_allocator_used_bytes_do_not_use_chunk_iterator to main April 26, 2026 22:02
@graphite-app graphite-app Bot merged commit f8422e2 into main Apr 26, 2026
38 checks passed
@graphite-app graphite-app Bot deleted the om/04-26-refactor_allocator_replace_chunkfooter_is_empty_with_free_function branch April 26, 2026 22:03
@overlookmotel overlookmotel added C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior A-allocator Area - Allocator labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocator Area - Allocator C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants