Skip to content

perf(multitude): optimize hot allocation paths and harden chunk lifecycle#498

Open
geeknoid wants to merge 1 commit into
mainfrom
multitude
Open

perf(multitude): optimize hot allocation paths and harden chunk lifecycle#498
geeknoid wants to merge 1 commit into
mainfrom
multitude

Conversation

@geeknoid

Copy link
Copy Markdown
Member

Follow-up to the multitude rewrite focused on allocation throughput, memory-safety hardening, and richer runtime accounting.

Copilot AI review requested due to automatic review settings June 12, 2026 13:58
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

⚠️ Breaking Changes Detected


--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/inherent_method_missing.ron

Failed in:
  Utf16String::into_arena_box_utf16_str, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/1f0b5970b95b02ee08d19ac3d38733fabb2e06f6/crates/multitude/src/strings/utf16_string.rs:320
  String::into_arena_box_str, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/1f0b5970b95b02ee08d19ac3d38733fabb2e06f6/crates/multitude/src/strings/string.rs:320
  Vec::into_arena_arc, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/1f0b5970b95b02ee08d19ac3d38733fabb2e06f6/crates/multitude/src/vec/freeze.rs:23
  Vec::try_into_arena_arc, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/1f0b5970b95b02ee08d19ac3d38733fabb2e06f6/crates/multitude/src/vec/freeze.rs:45
  Vec::into_arena_box, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/1f0b5970b95b02ee08d19ac3d38733fabb2e06f6/crates/multitude/src/vec/freeze.rs:74

If the breaking changes are intentional then everything is fine - this message is merely informative.

Remember to apply a version number bump with the correct severity when publishing a version with breaking changes (1.x.x -> 2.x.x or 0.1.x -> 0.2.x).

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (fc13464) to head (97db72b).

Additional details and impacted files
@@           Coverage Diff           @@
##            main     #498    +/-   ##
=======================================
  Coverage   99.9%   100.0%            
=======================================
  Files        336      337     +1     
  Lines      24829    25213   +384     
=======================================
+ Hits       24818    25213   +395     
+ Misses        11        0    -11     

☔ 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 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 is a follow-up set of changes in multitude aimed at improving allocation throughput and strengthening chunk lifecycle correctness, while expanding runtime accounting and updating tests/benches/docs to reflect the new behaviors.

Changes:

  • Reworked shared-chunk refcounting (pre-credited surplus + local counter reconciliation) and hardened shared/local chunk lifecycle + freelist linkage.
  • Refactored hot allocation paths to reduce per-iteration overhead (precomputed sizes, cold-path extraction, len==0 fast paths, fewer overflow checks in tight loops).
  • Updated Vec freezing APIs (into_arc/into_box renames, plus new into_slice/into_slice_mut) and adjusted tests/benchmarks/perf reporting accordingly.

Reviewed changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
crates/multitude/tests/utf16.rs Renames a test to match updated Vec/freeze naming.
crates/multitude/tests/mutants_extras.rs Updates mutant-kill tests and comments for renamed/changed freeze APIs.
crates/multitude/tests/mutant_kills_post_fix.rs Removes stats byte-count mutant-kill tests aligned with new stats semantics.
crates/multitude/tests/mutant_kills_more.rs Narrows mutant-kill scope now that stats byte-count recording is removed.
crates/multitude/tests/dst.rs Updates into_* calls and related commentary to into_box.
crates/multitude/tests/coverage_gaps.rs Renames try_into_* coverage module/tests to try_into_arc.
crates/multitude/tests/coverage_extras.rs Updates coverage tests for into_arc/into_box naming.
crates/multitude/tests/bolero.rs Updates lifecycle fuzz tests to use into_arc/into_box; adjusts stats assertions.
crates/multitude/tests/audit_repro.rs Adds regression test for ZST shared handouts advancing cursor (audit finding).
crates/multitude/tests/arena.rs Updates a stats/mutant test to use into_box.
crates/multitude/tests/arena_vec.rs Adds stats regression test for releasing retired oversized chunks on growth.
crates/multitude/tests/alloc_ref.rs Replaces/expands stats tests to validate live wasted_tail_bytes behavior.
crates/multitude/src/vec/mutate.rs Minor doc tweak related to shrink_to_fit arithmetic helper.
crates/multitude/src/vec/mod.rs Updates module docs for new into_arc/into_box names; grow path releases retired oversized chunks.
crates/multitude/src/vec/freeze.rs Renames freeze APIs and adds into_slice/into_slice_mut for O(1) arena-tied freezing.
crates/multitude/src/vec/basic.rs Optimizes extend_from_slice capacity check to avoid hot-path overflow guards.
crates/multitude/src/strings/utf16_string.rs Simplifies imports/paths and uses Vec/FromIteratorIn re-exports consistently.
crates/multitude/src/strings/string.rs Same as above for UTF-8 String builder.
crates/multitude/src/lib.rs Updates top-level docs for renamed freeze APIs and updated usage wording.
crates/multitude/src/internal/uninit.rs Minor formatting cleanup.
crates/multitude/src/internal/shared_chunk.rs Moves cache freelist link into header, adds wasted-tail retire tracking, and adds ref surplus helpers.
crates/multitude/src/internal/local_chunk.rs Adds unified intrusive next link, wasted-tail retire tracking, and payload-contains helper.
crates/multitude/src/internal/drop_entry.rs Fixes drop-entry placement for unaligned payload starts; adds regression test.
crates/multitude/src/internal/chunk_provider.rs Adds live counters (bytes outstanding, wasted tail), alignment slack for oversized payloads, and updates cache linkage.
crates/multitude/src/internal/chunk_ops.rs Adds stats retire accounting hook for chunk mutator drop/forget paths.
crates/multitude/src/internal/chunk_mutator.rs Refactors payload range math, adds wasted-tail computation, and de-duplicates prefixed-slice allocation internals.
crates/multitude/src/internal/chunk_alloc.rs Pads DST allocation layout to alignment to avoid UB when forming fat references.
crates/multitude/src/internal/arena_buf.rs Removes empty-slice early return; relies on well-defined zero-length memcpy.
crates/multitude/src/arena/retired_local.rs Introduces intrusive retired-local-chunk list replacing Vec<ChunkMutator<...>>.
crates/multitude/src/arena/reserve.rs Adds “with precomputed size” reserve helpers for hot slice-copy paths.
crates/multitude/src/arena/mod.rs Adds shared ref surplus tracking, retired-local list integration, and updated stats aggregation.
crates/multitude/src/arena/alloc_value.rs Extracts cold oversized paths; adds ZST shared-handout cursor-advance guard; integrates new shared-ref acquisition.
crates/multitude/src/arena/alloc_utf16.rs Adjusts utf16 alloc APIs to use new shared-ref acquisition and import paths.
crates/multitude/src/arena/alloc_unsized.rs Uses new shared-ref acquisition for DST allocations; removes old stats byte accounting.
crates/multitude/src/arena/alloc_str.rs Removes old stats byte accounting on string alloc paths.
crates/multitude/src/arena/alloc_slice_ref.rs Adds len==0 fast paths + precomputed-size helpers; extracts cold oversized/callsite-spill avoidance.
crates/multitude/src/arena/alloc_slice_box.rs Hoists payload byte computations; uses new shared-slice reserve-with-size helper.
crates/multitude/src/arena/alloc_slice_arc.rs Same as above for Arc<[T]> slice allocations.
crates/multitude/src/arena/alloc_prefixed.rs Uses new shared-ref acquisition; minor cleanup of DropEntry size/align usage.
crates/multitude/src/arena_stats.rs Updates high-level docs to reflect which fields are live gauges vs lifetime counters.
crates/multitude/src/arc.rs Updates From<Vec> conversion to use into_arc.
crates/multitude/src/allocator_impl.rs Uses new shared-ref acquisition for allocator-API2 bridge allocations.
crates/multitude/scripts/perf_report.rs Renames benchmark identifiers/groups for consistency with updated benches.
crates/multitude/README.md Regenerates crate README to reflect renamed APIs and updated perf naming.
crates/multitude/examples/multitude_basic.rs Updates example to use into_arc.
crates/multitude/docs/TODO.md Removes now-obsolete TODO list after landing the described items.
crates/multitude/docs/PERF.md Updates published perf table entries/names for the new benchmark identifiers.
crates/multitude/benches/gungraun_drop/linux.rs Renames drop benchmarks to match perf-report naming.
crates/multitude/benches/gungraun_alloc/linux.rs Updates bench names and reduces unnecessary black_box(&x) patterns; uses into_slice_mut for vec benches.
crates/multitude/benches/criterion_alloc.rs Splits warm_arena into local/shared variants to avoid dead-weight chunk priming; updates vec/string freeze benches.

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

Comment thread crates/multitude/src/lib.rs Outdated
Comment thread crates/multitude/README.md Outdated
Comment thread crates/multitude/src/arena/retired_local.rs
Comment thread crates/multitude/src/arena/retired_local.rs
Comment thread crates/multitude/tests/mutants_extras.rs Outdated
Comment thread crates/multitude/tests/mutants_extras.rs Outdated
Comment thread crates/multitude/src/arena/mod.rs
Copilot AI review requested due to automatic review settings June 12, 2026 17:38

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 58 out of 58 changed files in this pull request and generated 5 comments.

Comment thread crates/multitude/src/vec/freeze.rs
Comment thread crates/multitude/src/vec/freeze.rs
Comment thread crates/multitude/src/internal/arena_buf.rs Outdated
Comment thread crates/multitude/src/internal/shared_chunk.rs
Comment thread crates/multitude/src/internal/local_chunk.rs
Copilot AI review requested due to automatic review settings June 12, 2026 18:11

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 58 out of 58 changed files in this pull request and generated 2 comments.

Comment thread crates/multitude/src/internal/chunk_alloc.rs Outdated
Comment thread crates/multitude/src/internal/arena_buf.rs Outdated
@geeknoid geeknoid force-pushed the multitude branch 2 times, most recently from 72d55ab to 505a8c1 Compare June 12, 2026 21:47
Copilot AI review requested due to automatic review settings June 12, 2026 21:47

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 59 out of 59 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (1)

crates/multitude/src/lib.rs:270

  • The crate-level docs still claim the UTF-16 builder freeze is O(1) and “reuses the buffer in place”, but Utf16String::into_box now delegates to Arena::alloc_utf16_str_box(...), which copies into a fresh shared allocation (O(n)). This is user-facing and will mislead performance expectations.

Comment thread crates/multitude/tests/mutants_extras.rs Outdated
Comment thread crates/multitude/tests/mutants_extras.rs
Comment thread crates/multitude/tests/mutants_extras.rs Outdated
Comment thread crates/multitude/tests/arena.rs Outdated
Comment thread crates/multitude/tests/arena_vec.rs
Comment thread crates/multitude/tests/coverage_extras.rs
Comment thread crates/multitude/tests/coverage_extras.rs
Comment thread crates/multitude/tests/coverage_extras.rs
Comment thread crates/multitude/tests/coverage_extras.rs
…ycle

Follow-up to the multitude rewrite focused on allocation throughput,
memory-safety hardening, and richer runtime accounting.
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.

2 participants