Skip to content

feat(concurrency): use parking_lot for the default backend#1541

Closed
daniel-noland wants to merge 1 commit into
pr/daniel-noland/concurrency-stack/2-facade-stdfrom
pr/daniel-noland/concurrency-stack/3-facade-parking-lot
Closed

feat(concurrency): use parking_lot for the default backend#1541
daniel-noland wants to merge 1 commit into
pr/daniel-noland/concurrency-stack/2-facade-stdfrom
pr/daniel-noland/concurrency-stack/3-facade-parking-lot

Conversation

@daniel-noland
Copy link
Copy Markdown
Collaborator

@daniel-noland daniel-noland commented May 15, 2026

Summary

  • Add a parking_lot Cargo feature (enabled by default) and a concurrency/src/sync/parking_lot_backend.rs that is a zero-cost re-export of parking_lot::{Mutex, RwLock} plus the std re-exports for everything parking_lot doesn't ship (Arc, Weak, atomics, Condvar, ...).
  • Backend routing in concurrency/src/sync/mod.rs picks parking_lot_backend when feature = "parking_lot" is on, falls back to std_backend otherwise.
  • _strict_provenance feature overrides parking_lot and routes through std_backend: parking_lot_core::word_lock uses integer-to-pointer casts that -Zmiri-strict-provenance rejects, and the CI miri job (--features=_strict_provenance) exercises the fallback slot, which needs std::sync underneath.
  • Workspace Cargo.toml gets a tokio parking_lot override entry so the tokio parking_lot feature is enabled workspace-wide.

PR 3 of 6. Depends on #1540 — facade-std. The next PR sweeps the workspace data-path crates to consume the facade.

@daniel-noland daniel-noland force-pushed the pr/daniel-noland/concurrency-stack/3-facade-parking-lot branch from d560e77 to aa509ce Compare May 15, 2026 21:17
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/concurrency-stack/2-facade-std branch from c712d12 to 8c6ea48 Compare May 15, 2026 21:17
Adds `parking_lot` as the production backend behind the
`parking_lot` feature, and turns that feature on by default.
`parking_lot::{Mutex, RwLock}` already match the surface this crate
presents -- naked guards, no poison, fast contention path -- so the
default backend now pays no wrapping cost. Production builds get
the perf path; `--no-default-features` falls back to the
`std_backend` poison-as-panic wrapper from the previous PR.

* `concurrency::sync::parking_lot_backend` re-exports
  `parking_lot::{Mutex, RwLock, ...Guard}` and the
  `parking_lot`-shaped surface for `RwLockUpgradableReadGuard`
  (`upgrade()` / `try_upgrade()` are inherited directly). Other
  std-only types (`Arc`, `Weak`, `atomic`, `mpsc`, `Once`,
  `OnceLock`, `Barrier`, `Condvar`) come straight from `std::sync`.
* `concurrency/src/sync/mod.rs` routes: `parking_lot` feature on
  (default) -> parking_lot backend; `parking_lot` feature off ->
  `std_backend`; loom / shuttle features keep their raw re-exports.

Workspace `Cargo.toml` adds `tokio/parking_lot` as a documented
exception to the "no workspace-wide features" rule. Without it,
tokio's runtime picks a different lock implementation than the
rest of the dataplane, which is divergence we don't want between
test binaries and the real dataplane process.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/concurrency-stack/3-facade-parking-lot branch from aa509ce to cdf3507 Compare May 15, 2026 21:22
@daniel-noland daniel-noland force-pushed the pr/daniel-noland/concurrency-stack/2-facade-std branch from 8c6ea48 to 734ff09 Compare May 15, 2026 21:22
@daniel-noland
Copy link
Copy Markdown
Collaborator Author

Folded into #1542 — same reason as #1540.

@daniel-noland daniel-noland deleted the pr/daniel-noland/concurrency-stack/3-facade-parking-lot branch May 15, 2026 21:39
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.

1 participant