Skip to content

fix: Fix bug in Arena::reset leading to over allocation#508

Open
geeknoid wants to merge 1 commit into
mainfrom
multitwo
Open

fix: Fix bug in Arena::reset leading to over allocation#508
geeknoid wants to merge 1 commit into
mainfrom
multitwo

Conversation

@geeknoid

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 17, 2026 13:00
@geeknoid geeknoid changed the title Fix bug in Arena::reset leading to over allocation fix: Fix bug in Arena::reset leading to over allocation Jun 17, 2026
Comment thread crates/multitude/benches/criterion_arc_array.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses an over-allocation bug in multitude::Arena::reset by ensuring reset only affects local-chunk state (instead of also retiring/clearing shared-chunk state), and it updates allocation routing helpers and regression coverage accordingly.

Changes:

  • Adjust Arena::reset to stop detaching/emptying the current shared chunk (preventing “one new shared chunk per reset cycle” growth patterns).
  • Consolidate oversized-allocation threshold checks into a single is_oversized helper and update call sites.
  • Expand regression tests (including loom scenarios) and add new benches to measure/track the affected workload patterns.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/multitude/src/arena/mod.rs Changes reset behavior; unifies oversized routing helper documentation and usage.
crates/multitude/src/vec/mod.rs Updates vec growth path to use the unified is_oversized.
crates/multitude/src/arena/alloc_value.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_utf16.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_unsized.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_str.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_slice_ref.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_slice_box.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_slice_arc.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/arena/alloc_prefixed.rs Updates oversized routing checks to is_oversized.
crates/multitude/src/allocator_impl.rs Updates allocator impl oversized routing to is_oversized.
crates/multitude/tests/arena.rs Adds regression tests validating shared-chunk stability and nested-Arc validity across reset cycles.
crates/multitude/tests/alloc_ref.rs Refines wasted-tail invariants to reflect local-vs-shared reset semantics.
crates/multitude/tests/loom.rs Renames/retargets loom tests to reflect reset-vs-drop semantics around shared chunks.
crates/multitude/tests/mutant_kills_post_fix.rs Updates post-fix mutant test commentary for the renamed oversized helper.
crates/multitude/tests/zst_uninit_arc_fix.rs Updates regression comment to the unified is_oversized naming.
crates/multitude/Cargo.toml Adds dev-dep + bench targets for the new arc-array benchmarks.
crates/multitude/benches/criterion_arc_array.rs Introduces a criterion benchmark intended to compare global vs arena-backed arc-array builds.
crates/multitude/benches/gungraun_arc_array/main.rs Adds a gungraun benchmark entrypoint for instruction-precise arc-array builds.
crates/multitude/benches/gungraun_arc_array/linux.rs Implements the Linux-only gungraun arc-array benchmark bodies and setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/multitude/src/arena/mod.rs
Comment thread crates/multitude/benches/criterion_arc_array.rs
Comment thread crates/multitude/benches/criterion_arc_array.rs
Comment thread crates/multitude/benches/criterion_arc_array.rs Outdated
Comment thread crates/multitude/tests/mutant_kills_post_fix.rs Outdated
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (b190aba) to head (8271c0b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #508   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         343      343           
  Lines       26121    26116    -5     
=======================================
- Hits        26121    26116    -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings June 17, 2026 13:17
@geeknoid geeknoid force-pushed the multitwo branch 2 times, most recently from 9f5e9d7 to 3e9320e Compare June 17, 2026 13:25
@geeknoid geeknoid enabled auto-merge (squash) June 17, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

crates/multitude/src/arena/alloc_utf16.rs:189

  • This loop reserves total bytes with elem_align, but routes oversized allocations and refills based on total alone. Because try_alloc may need up to elem_align - 1 bytes of alignment padding at the front of the reservation, using total for is_oversized/refill_shared can miss the max-normal boundary and lead to repeated refills. Using a refill_hint = total + elem_align for routing/refill (while still reserving total) avoids the total vs total + align mismatch.
            if self.is_oversized(total) {
                return self.alloc_oversized_shared_with(total, |mutator, chunk_ptr| {
                    let (base, _chunk_unused) = mutator
                        .try_alloc_with_chunk(total, elem_align)
                        .expect("dedicated oversized chunk sized to fit utf-16 payload");

Comment thread crates/multitude/src/arena/alloc_prefixed.rs
Copilot AI review requested due to automatic review settings June 17, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated 1 comment.

Comment thread crates/multitude/tests/utf16.rs
@martintmk

Copy link
Copy Markdown
Member

I tried to rebase my example:
#509

on top of this change and I was hoping the amount of allocations will drop significantly, but that was not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants