Skip to content

feat(multitude): add arena-aware Serde and harden allocation safety#587

Open
geeknoid wants to merge 2 commits into
mainfrom
multitude
Open

feat(multitude): add arena-aware Serde and harden allocation safety#587
geeknoid wants to merge 2 commits into
mainfrom
multitude

Conversation

@geeknoid

@geeknoid geeknoid commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Add allocator-backed deserialization traits, derive support, recursive containers, borrow-or-arena strings, dynamic values, capacity reuse, resource limits, and optional JSON helpers.
  • Harden chunk ownership and cross-thread teardown by sharing allocator state safely, tighten Send/Sync bounds, and fix ZST drain and Rc overflow handling.
  • Align allocation benchmarks and performance reporting with bumpalo, add representative Serde benchmarks and examples, and refresh architecture and performance documentation.

Validation

  • Comprehensive unit, integration, property, malformed-input, Miri, and Loom coverage.
  • 100% LLVM line coverage for the new serialization runtime and derive implementation.

Copilot AI review requested due to automatic review settings July 17, 2026 15:27

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 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> in Chunk/ChunkProvider and tighten Send/Sync bounds to require A: Send + Sync where cross-thread chunk teardown is possible.
  • Fix Drain’s drop path for zero-sized types by avoiding offset_from on dangling ZST pointers; add regression test coverage.
  • Add tests reproducing the “large allocator state displaces header” issue and expand assume_init documentation; 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.

Comment thread crates/multitude/src/internal/chunk.rs Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 15:32
Comment thread crates/multitude/src/internal/chunk.rs
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 3 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
multitude 0.6.1 ddbfcd1 0.6.2 0.6.2 ✅ ok
multitude_macros new crate 0.1.0 0.1.0 ✅ ok
multitude_macros_impl new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

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 15 out of 16 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 15:37
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (ba34d62) to head (29837b6).

Additional details and impacted files
@@            Coverage Diff            @@
##             main     #587     +/-   ##
=========================================
  Coverage   100.0%   100.0%             
=========================================
  Files         359      375     +16     
  Lines       27885    30664   +2779     
=========================================
+ Hits        27885    30664   +2779     
Flag Coverage Δ
linux 90.4% <100.0%> (-9.6%) ⬇️
linux-arm 90.4% <100.0%> (-9.6%) ⬇️
scheduled ?
windows 90.4% <100.0%> (-9.6%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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

Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.

Comment thread crates/multitude/tests/send_sync.rs
Copilot AI review requested due to automatic review settings July 17, 2026 16:56

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 16 out of 17 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 17:49

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 16 out of 17 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 18:17

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 27 out of 28 changed files in this pull request and generated 1 comment.

Comment thread crates/multitude/src/rc.rs Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 19:31
Copilot AI review requested due to automatic review settings July 18, 2026 06:57

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 90 out of 92 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

crates/multitude_macros/README.md:2

  • README references ./logo.png, but no such file exists in this crate, so the header image will be broken on GitHub/crates.io/docs.rs renders. Either add the image (non-LFS, included in the published crate) or point this to an existing asset (e.g. the repo-level logo.svg).
    crates/multitude_macros_impl/README.md:2
  • README references ./logo.png, but no such file exists in this crate, so the header image will be broken on GitHub/crates.io/docs.rs renders. Either add the image (non-LFS, included in the published crate) or point this to an existing asset (e.g. the repo-level logo.svg).

Copilot AI review requested due to automatic review settings July 18, 2026 08:28

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 90 out of 92 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

crates/multitude_macros/README.md:2

  • README references ./logo.png, but that file is not present in this crate directory, so the image will render as a broken link. Either add the missing asset or point to an existing logo file in the repo.
    crates/multitude_macros_impl/README.md:2
  • README references ./logo.png, but that file is not present in this crate directory, so the image will render as a broken link. Either add the missing asset or point to an existing logo file in the repo.

Copilot AI review requested due to automatic review settings July 18, 2026 09:55

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 90 out of 92 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

crates/multitude_macros/README.md:3

  • This README references local assets (./logo.png and ../../logo.svg). The workspace packaging allowlist (workspace.package include) does not include images or repo-root assets like logo.svg, so these links will be broken on crates.io/docs.rs. Prefer absolute URLs for badges/logos (also aligns with the packaging guideline to reference binary assets by URL).
    crates/multitude_macros_impl/README.md:3
  • This README references local assets (./logo.png and ../../logo.svg). The workspace packaging allowlist (workspace.package include) does not include images or repo-root assets like logo.svg, so these links will be broken on crates.io/docs.rs. Prefer absolute URLs for badges/logos (also aligns with the packaging guideline to reference binary assets by URL).

Comment thread crates/multitude/src/rc.rs Outdated
Add allocator-backed deserialization traits, derive support, recursive containers, dynamic values, reuse, limits, and JSON helpers.

Harden chunk ownership and thread-safety, fix ZST drain and Rc overflow handling, and align benchmarks and reporting with bumpalo.
Copilot AI review requested due to automatic review settings July 18, 2026 12:21

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 90 out of 92 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

crates/multitude_macros/README.md:2

  • The README references ./logo.png, but crates/multitude_macros/logo.png is not present in the repo, so the image will be broken anywhere the README is rendered. Add the expected logo.png (matching other crates’ README template) or adjust the README/template to point at an existing asset.
    crates/multitude_macros_impl/README.md:2
  • The README references ./logo.png, but crates/multitude_macros_impl/logo.png is not present in the repo, so the image will be broken anywhere the README is rendered. Add the expected logo.png (matching other crates’ README template) or adjust the README/template to point at an existing asset.

Copilot AI review requested due to automatic review settings July 18, 2026 13:57

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

Copilot AI review requested due to automatic review settings July 18, 2026 14:18

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

Copilot AI review requested due to automatic review settings July 18, 2026 14:41
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: fa351567-09e0-4465-939b-b07b1a8ca841

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

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