Skip to content

feat: support type erasure of pooled handles to unsized types#585

Open
geeknoid wants to merge 1 commit into
mainfrom
plurality
Open

feat: support type erasure of pooled handles to unsized types#585
geeknoid wants to merge 1 commit into
mainfrom
plurality

Conversation

@geeknoid

Copy link
Copy Markdown
Member
  • Onboard bytesbuf and layered to plurality

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 1 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
plurality 0.1.0 b18c99c 0.1.1 0.1.1 ✅ ok

This check is informational and does not block the merge.

View the check run

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

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 extends the plurality pooled-handle model to support type erasure to unsized types (dyn Trait and slices) for owning/shared handles, and migrates consumers (notably bytesbuf and layered) away from infinity_pool to plurality.

Changes:

  • Add DST/type-erasure support for plurality::Box, plurality::Arc, and plurality::Rc via unsize::Coercion, including erased reclaim logic in the pool.
  • Expand correctness + fuzz/property + allocation-tracking tests, plus new benchmark coverage for fat-pointer owning handles.
  • Migrate downstream crates to use plurality instead of infinity_pool, and update supporting docs/scripts/CI helpers.

Reviewed changes

Copilot reviewed 40 out of 42 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
justfiles/extended.just Ensure Loom runs with the loom feature enabled when executing loom_*.rs tests.
crates/plurality/tests/unsize.rs New integration tests covering Box/Arc/Rc unsizing to trait objects/slices and drop/reclaim behavior.
crates/plurality/tests/smart_ptr.rs Extend smart-pointer behavior assertions (ordering/hash set semantics).
crates/plurality/tests/pool.rs Add regression test coverage for panicking destructors returning slots.
crates/plurality/tests/loom_pool.rs Update Loom test invocation docs to match new test target/feature usage.
crates/plurality/tests/box.rs Add into_raw/from_raw round-trip tests for pooled Box.
crates/plurality/tests/bolero_pool.rs New Bolero property/fuzz test for core pool invariants.
crates/plurality/tests/alloc.rs Add regression test for panicking destructors returning local slots.
crates/plurality/tests/alloc_tracking.rs Add allocation-tracking assertions for the new dyn-box benchmark bodies.
crates/plurality/src/sync.rs Make Arc<T> support T: ?Sized and add Arc::unsize; use erased drop/reclaim.
crates/plurality/src/slot.rs Add MAX_POOL_SLOTS cap helper and clarify refcount/free-link semantics.
crates/plurality/src/rc.rs Make Rc<T> support T: ?Sized and add Rc::unsize; refcount via erased offsets.
crates/plurality/src/pool.rs Introduce PoolCore for erased teardown; implement erased reclaim from value ptr + size/align.
crates/plurality/src/lib.rs Document type erasure and re-export unsize::Coercion from the crate API.
crates/plurality/src/common.rs Add shared impl macros for T: ?Sized handles and update handle-layout docs.
crates/plurality/src/chunk.rs Remove type parameters from ChunkHeader and related layout/addressing helpers.
crates/plurality/src/builder.rs Build PoolCore with a concrete teardown callback; validate caps via MAX_POOL_SLOTS.
crates/plurality/src/boxed.rs Make Box<T> support T: ?Sized, add Box::unsize + into_raw/from_raw, and erased drop path.
crates/plurality/src/alloced.rs Update Alloc drop path to new local-free API shape.
crates/plurality/scripts/perf_report.rs Extend PERF report generation to include dyn-box benchmarks and ratio formatting.
crates/plurality/scripts/correctness.rs Update correctness harness to new Loom/Bolero test target names and flags.
crates/plurality/README.md Regenerate crate README with new type-erasure API docs and links.
crates/plurality/docs/PERF.md Update published performance report with new operations + dyn-box comparison section.
crates/plurality/docs/DESIGN.md Update design doc to reflect erased handles, PoolCore, and new recovery strategy.
crates/plurality/Cargo.toml Bump version; add unsize dep; add dyn-box benches; rename loom test target; move dev-deps.
crates/plurality/benches/shared/ops.rs Add Marker trait and unsize operations used by alloc benchmarks.
crates/plurality/benches/shared/dyn_box_ops.rs New shared bodies for fat-pointer owning-handle cross-crate comparison.
crates/plurality/benches/gungraun_dyn_box/main.rs New Callgrind bench harness for dyn-box comparison.
crates/plurality/benches/gungraun_dyn_box/linux.rs Linux implementation of dyn-box Callgrind benches.
crates/plurality/benches/gungraun_alloc/linux.rs Add box_unsize/arc_unsize to alloc Callgrind suite.
crates/plurality/benches/criterion_dyn_box.rs New wall-clock criterion benches for dyn-box comparison.
crates/plurality/benches/criterion_alloc.rs Add box_unsize/arc_unsize to criterion allocation suite.
crates/layered/src/dynamic.rs Switch dynamic-service implementation from infinity_pool to plurality with boxed DST handles.
crates/layered/Cargo.toml Replace infinity_pool feature/deps with optional plurality.
crates/fetch/Cargo.toml Formatting-only update to native-tls feature list.
crates/data_privacy_macros_impl/Cargo.toml Formatting-only update to allowed external types list.
crates/bytesbuf/src/mem/global.rs Replace raw infinity_pool block pooling with plurality, using raw-handle escape for self-handle.
crates/bytesbuf/Cargo.toml Replace infinity_pool dependency with plurality.
crates/bytesbuf_io/Cargo.toml Formatting-only update to categories.
Cargo.toml Bump plurality workspace dependency version and add unsize workspace dependency.
Cargo.lock Lockfile updates for plurality 0.1.1 and new unsize dependency usage.
.spelling Add unsize/unsizing to spelling allowlist.

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

Comment thread crates/plurality/src/rc.rs Outdated
Comment thread crates/plurality/tests/unsize.rs
Comment thread crates/bytesbuf/src/mem/global.rs Outdated
@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 (98b21d7).

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #585    +/-   ##
========================================
  Coverage   100.0%   100.0%            
========================================
  Files         359      359            
  Lines       27885    28066   +181     
========================================
+ Hits        27885    28066   +181     
Flag Coverage Δ
linux 94.0% <100.0%> (?)
linux-arm 93.6% <100.0%> (?)
windows 94.5% <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 review requested due to automatic review settings July 17, 2026 07:03

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

Comment thread crates/plurality/tests/unsize.rs
Copilot AI review requested due to automatic review settings July 17, 2026 07:23

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

Comment thread crates/bytesbuf/src/mem/global.rs
Comment thread crates/plurality/benches/gungraun_dyn_box/linux.rs Outdated
Comment thread crates/plurality/docs/DESIGN.md Outdated
Comment thread crates/plurality/src/lib.rs Outdated
Comment thread crates/plurality/src/lib.rs
Comment thread crates/plurality/src/lib.rs
Comment thread crates/plurality/src/pool.rs
Comment thread crates/layered/src/dynamic.rs Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 12: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.

Pull request overview

Copilot reviewed 40 out of 42 changed files in this pull request and generated 2 comments.

Comment thread crates/bytesbuf/src/mem/global.rs Outdated
Comment thread crates/plurality/src/pool.rs Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 12:34

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

Comment thread crates/plurality/src/pool.rs
Comment thread crates/plurality/src/chunk.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

Copilot reviewed 43 out of 45 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

crates/layered/Cargo.toml:47

  • dynamic module is compiled for unit tests (#[cfg(any(test, feature = "dynamic-service"))] in src/lib.rs), but plurality is only an optional dependency. As-is, cargo test -p layered without --features dynamic-service will still compile src/dynamic.rs and fail to resolve the plurality crate. Add plurality as a non-optional dev-dependency (mirroring the old infinity_pool setup), or gate the module strictly behind the feature.
[features]
default = []
intercept = []
dynamic-service = ["dep:plurality"]
tower-service = ["dep:tower-service"]

[dependencies]
plurality = { workspace = true, optional = true }
tower-layer = { workspace = true }
tower-service = { workspace = true, optional = true }

[dev-dependencies]
alloc_tracker = { workspace = true }
criterion = { workspace = true }
futures = { workspace = true, features = ["executor"] }
mutants = { workspace = true }
pin-project-lite = { workspace = true }
static_assertions = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tower = { workspace = true, features = ["limit", "util"] }
tower-service = { workspace = true }

Comment thread crates/layered/src/dynamic.rs
Copilot AI review requested due to automatic review settings July 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 43 out of 45 changed files in this pull request and generated no new comments.

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

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

Comment thread crates/bytesbuf/src/mem/global.rs
Comment thread crates/layered/src/dynamic.rs Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 13:55
Comment thread crates/plurality/docs/DESIGN.md Outdated
Comment thread crates/plurality/src/lib.rs Outdated
Comment thread crates/bytesbuf/src/mem/global.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

Copilot reviewed 43 out of 45 changed files in this pull request and generated 2 comments.

Comment thread crates/plurality/benches/gungraun/ops.rs Outdated
Comment thread crates/plurality/benches/criterion/ops.rs Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 14:02
@geeknoid
geeknoid force-pushed the plurality branch 2 times, most recently from 8785751 to 5b90a60 Compare July 17, 2026 14:05

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

Copilot AI review requested due to automatic review settings July 17, 2026 14:09
@geeknoid geeknoid changed the title feat(plurality): support type erasure of pooled handles to unsized types feat: support type erasure of pooled handles to unsized types Jul 17, 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.

Pull request overview

Copilot reviewed 42 out of 44 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 14:14
@geeknoid
geeknoid enabled auto-merge (squash) July 17, 2026 14: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 42 out of 44 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown

⚠️ Potential breaking changes detected

cargo semver-checks flagged the following on this PR. This is informational -- breaking changes between commits are expected; the major-version bump happens at release time, not on every PR.

fetch

    Building fetch v0.13.0 (current)
       Built [  35.483s] (current)
     Parsing fetch v0.13.0 (current)
      Parsed [   0.007s] (current)
    Building fetch v0.13.0 (baseline)
       Built [  34.460s] (baseline)
     Parsing fetch v0.13.0 (baseline)
      Parsed [   0.007s] (baseline)
    Checking fetch v0.13.0 -> v0.13.0 (no change; assume minor)
     Checked [   0.019s] 196 checks: 194 pass, 2 fail, 0 warn, 49 skip

     Summary semver requires new major version: 2 major and 0 minor checks failed
    Finished [  71.510s] fetch

--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters, not counting the receiver (self) parameter.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/method_parameter_count_changed.ron

Failed in:
  fetch::handlers::Metrics::layer now takes 0 parameters instead of 1, in /home/runner/work/oxidizer/oxidizer/crates/fetch/src/handlers/metrics.rs:235
  fetch::handlers::Logging::layer now takes 0 parameters instead of 2, in /home/runner/work/oxidizer/oxidizer/crates/fetch/src/handlers/logging.rs:43

--- failure method_requires_different_generic_type_params: method now requires a different number of generic type parameters ---

Description:
A method now requires a different number of generic type parameters than it used to. Uses of this method that supplied the previous number of generic types will be broken.
        ref: https://doc.rust-lang.org/reference/items/generics.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/method_requires_different_generic_type_params.ron

Failed in:
  fetch::HttpClientBuilder::meter_provider takes 1 generic types instead of 0, in /home/runner/work/oxidizer/oxidizer/crates/fetch/src/client_builder.rs:254

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