Skip to content

refactor(allocator): reduce scope of unsafe blocks in Arena chunk iterators#21778

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

refactor(allocator): reduce scope of unsafe blocks in Arena chunk iterators#21778
graphite-app[bot] merged 1 commit intomainfrom
om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 26, 2026

Pure refactor. Arena's 2 chunk iterators' next methods were each enclosed in a single unsafe { ... } block with no safety comments. Reduce the scope of unsafe blocks to just the statements where they're required, and add // SAFETY comments.

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_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators (6889c46) with om/04-26-fix_allocator_arena_retry_allocation_when_chunk_size_approaches_maximum (674dfac)

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 force-pushed the om/04-26-fix_allocator_arena_retry_allocation_when_chunk_size_approaches_maximum branch from 1618da5 to c5ed4e8 Compare April 26, 2026 12:27
@overlookmotel overlookmotel force-pushed the om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators branch from 67ff1f2 to a82c143 Compare April 26, 2026 12:27
@overlookmotel overlookmotel marked this pull request as ready for review April 26, 2026 18:42
Copilot AI review requested due to automatic review settings April 26, 2026 18:42
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 Arena’s chunk iterators to narrow unsafe blocks down to only the operations that require them, and adds focused // SAFETY: comments to document the invariants relied upon.

Changes:

  • Refactor ChunkIter::next to move unsafe to only the as_ref() dereference of the constructed slice pointer.
  • Refactor ChunkRawIter::next to move unsafe to only footer_ptr.as_ref() and offset_from_unsigned(...), with added // SAFETY: explanations.

@overlookmotel overlookmotel force-pushed the om/04-26-fix_allocator_arena_retry_allocation_when_chunk_size_approaches_maximum branch from c5ed4e8 to 831cf9e Compare April 26, 2026 20:47
@overlookmotel overlookmotel force-pushed the om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators branch from a82c143 to 1d77796 Compare April 26, 2026 20:47
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 26, 2026

Merge activity

… iterators (#21778)

Pure refactor. `Arena`'s 2 chunk iterators' `next` methods were each enclosed in a single `unsafe { ... }` block with no safety comments. Reduce the scope of `unsafe` blocks to just the statements where they're required, and add `// SAFETY` comments.
@graphite-app graphite-app Bot force-pushed the om/04-26-fix_allocator_arena_retry_allocation_when_chunk_size_approaches_maximum branch from 831cf9e to 674dfac Compare April 26, 2026 21:52
@graphite-app graphite-app Bot requested a review from camc314 as a code owner April 26, 2026 21:52
@graphite-app graphite-app Bot force-pushed the om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators branch from 1d77796 to 6889c46 Compare April 26, 2026 21:52
Base automatically changed from om/04-26-fix_allocator_arena_retry_allocation_when_chunk_size_approaches_maximum to main April 26, 2026 22:08
@graphite-app graphite-app Bot merged commit 6889c46 into main Apr 26, 2026
38 checks passed
@graphite-app graphite-app Bot deleted the om/04-26-refactor_allocator_reduce_scope_of_unsafe_blocks_in_arena_chunk_iterators branch April 26, 2026 22:09
@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