Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens multitude’s chunk layout and concurrency guarantees by moving the backing allocator into a shared Arc<A> in chunk metadata, preventing allocator state from inflating the chunk header past the first 64 KiB tile (which smart-pointer header recovery relies on). It also fixes a ZST-specific Drain drop edge case, expands safety documentation for assume_init, and rewrites docs/DESIGN.md into a higher-level architecture and invariants overview.
Changes:
- Store the backing allocator as
Arc<A>inChunk/ChunkProviderand tightenSend/Syncbounds to requireA: Send + Syncwhere cross-thread chunk teardown is possible. - Fix
Drain’s drop path for zero-sized types by avoidingoffset_fromon dangling ZST pointers; add regression test coverage. - Add tests reproducing the “large allocator state displaces header” issue and expand
assume_initdocumentation; rewrite DESIGN documentation.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/multitude/tests/send_sync.rs | Adds a regression test ensuring Arena<A> is not Send when A is !Sync. |
| crates/multitude/tests/audit_repro.rs | Adds a large-allocator-state regression test ensuring smart pointers remain valid after arena drop. |
| crates/multitude/tests/arena_vec.rs | Adds a test ensuring ZST drain(..) drop restores tail and runs drops correctly. |
| crates/multitude/src/vec/drain.rs | Fixes ZST Drain drop behavior by avoiding pointer offset computation for ZSTs. |
| crates/multitude/src/rc.rs | Documents assume_init clone/leak footgun for Rc<MaybeUninit<...>>. |
| crates/multitude/src/internal/chunk.rs | Stores allocator as Arc<A>, updates alignment/header computations and related tests. |
| crates/multitude/src/internal/chunk_provider.rs | Stores allocator as Arc<A> and tightens Send/Sync impl bounds to A: Send + Sync. |
| crates/multitude/src/internal/chunk_mutator.rs | Tightens Send impl bound to A: Send + Sync to match allocator sharing semantics. |
| crates/multitude/src/arena/retired_local.rs | Tightens Send impl bound to A: Send + Sync for moved arenas with pinned chunks. |
| crates/multitude/src/arena/mod.rs | Updates Arena: Send rationale to reflect A: Send + Sync requirement. |
| crates/multitude/src/arc.rs | Documents assume_init clone/leak footgun for Arc<MaybeUninit<...>>. |
| crates/multitude/docs/DESIGN.md | Rewrites internal design doc into an architecture overview with invariants, failure modes, and concurrency model. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Version increments look sufficient
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #587 +/- ##
=========================================
Coverage 100.0% 100.0%
=========================================
Files 393 408 +15
Lines 33520 36702 +3182
=========================================
+ Hits 33520 36702 +3182
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add allocator-aware deserialization, derive support, arena-backed dynamic values, reusable buffers, resource limits, and JSON helpers. Introduce a generic arena-aware Cow with borrowed and arena-owned forms plus explicit allocator-aware cloning and mutation. Harden chunk ownership and thread safety, fix ZST drain and Rc overflow handling, and add matched Serde and teardown benchmarks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fa351567-09e0-4465-939b-b07b1a8ca841
Summary
Cowwith borrowed and arena-owned forms, fallible and infallible copy-on-write mutation, and explicit allocator-aware cloning.multitude::de, including derive support, recursive containers, arena-backed dynamic values, resource limits, JSON helpers, and ordinary-Serde interoperability.Send/Syncbounds, and fix ZST drain andRcoverflow handling.Validation
Cow, and derive implementation.