Skip to content

feat(multitude): add arena-aware Serde and Cow#587

Merged
geeknoid merged 1 commit into
mainfrom
multitude
Jul 23, 2026
Merged

feat(multitude): add arena-aware Serde and Cow#587
geeknoid merged 1 commit into
mainfrom
multitude

Conversation

@geeknoid

@geeknoid geeknoid commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a generic arena-aware Cow with borrowed and arena-owned forms, fallible and infallible copy-on-write mutation, and explicit allocator-aware cloning.
  • Add allocator-aware deserialization under multitude::de, including derive support, recursive containers, arena-backed dynamic values, resource limits, JSON helpers, and ordinary-Serde interoperability.
  • Add local and escape-capable root ownership plus inherent reusable deserialization for Multitude strings and vectors.
  • Harden chunk ownership and cross-thread teardown, tighten Send/Sync bounds, and fix ZST drain and Rc overflow handling.
  • Add matched Criterion and Callgrind benchmarks for Serde and allocation teardown, plus updated examples, architecture documentation, and generated performance reporting.

Validation

  • Full unit, integration, property, doctest, Miri, and Loom coverage.
  • Regression coverage for panic-safe cleanup, deserialization-limit enforcement, numeric replay, and derive hygiene.
  • 100% LLVM line coverage for the new deserialization runtime, generic Cow, 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 (1feffd7) to head (20bbb5e).

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     
Flag Coverage Δ
linux 84.3% <100.0%> (?)
linux-arm 84.3% <100.0%> (?)
windows 84.3% <100.0%> (?)

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
Comment thread crates/multitude/src/serialization/limits.rs Outdated
Comment thread crates/multitude/src/serialization/cow_str.rs Outdated
Comment thread crates/multitude/src/de/mod.rs
Copilot AI review requested due to automatic review settings July 20, 2026 19:04

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.

@geeknoid geeknoid changed the title feat(multitude): add arena-aware Serde and harden allocation safety feat(multitude): add arena-aware Serde support Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 20:02

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.

@geeknoid geeknoid changed the title feat(multitude): add arena-aware Serde support feat(multitude): add arena-aware Serde and Cow Jul 20, 2026

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 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 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 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 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 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 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 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 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 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 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 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.

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

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.

6 participants