parking_lot

A faster, smaller drop-in replacement for Rust's standard library Mutex, RwLock, Condvar, and Once.

Library
Cargo
v0.13.0
3,434 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
83 /100 Excellent
Development Activity 96
Maintenance 72
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
82 /100 Excellent
Architecture 88
Code Quality 82
Innovation 85
Learning Curve 74

parking_lot provides Mutex, RwLock, Condvar, and Once implementations that are smaller, faster, and more flexible than the ones in Rust’s standard library, plus a ReentrantMutex for recursive locking. It’s built on a low-level “parking lot” API (in the companion parking_lot_core crate) — the same design pattern used by WebKit’s JavaScriptCore — that manages queues of parked (blocked) threads efficiently, letting the higher-level lock types stay as small as a single byte or word instead of allocating OS-specific primitives on the heap.

Benchmarks in the README show parking_lot’s Mutex roughly 1.5x faster than std::sync::Mutex when uncontended and up to 5x faster under contention, with RwLock seeing gains up to 50x in some multi-reader scenarios. The crate is one of the most-depended-upon in the Rust ecosystem (nearly a billion total downloads), used transitively by countless other crates that need efficient synchronization primitives — including the type-safe generic lock API it publishes separately as lock_api, which other crates use to build their own custom lock types on the same fast core.

What You Get

  • Mutex, RwLock, Condvar, and Once types that are drop-in faster replacements for std::sync equivalents
  • A ReentrantMutex type supporting recursive locking, which std::sync does not provide
  • A low-level parking_lot_core API for building custom synchronization primitives on the same efficient thread-parking mechanism
  • lock_api, a type-safe generic lock API that other crates use to implement their own Mutex/RwLock-like types
  • Optional features: fair mutexes, hardware lock elision on supported x86 processors, deadlock detection, and serde support

Common Use Cases

  • Replacing std::sync::Mutex/RwLock in performance-sensitive multi-threaded Rust code to cut contention overhead
  • Building custom lock types on top of lock_api’s generic RawMutex/RawRwLock traits
  • Using ReentrantMutex where a thread may need to re-acquire a lock it already holds
  • Debugging deadlocks in production via the optional deadlock-detection feature that periodically scans for cycles

Under The Hood

Architecture — The crate’s public types (mutex.rs 385 lines, rwlock.rs 659 lines, condvar.rs 1,273 lines, once.rs 498 lines) are thin wrappers around raw primitive implementations (raw_mutex.rs, raw_rwlock.rs 1,158 lines) that in turn build on the separately-published parking_lot_core crate (in core/src/), which implements the actual parking-lot algorithm: a global hash table of wait queues (word_lock.rs, parking_lot.rs) that lets threads park/unpark without each lock needing its own OS-level primitive. lock_api sits alongside as a generic, type-safe trait layer (RawMutex, RawRwLock) that both this crate and third-party crates build concrete lock types on top of.

Tech Stack — Pure Rust with minimal dependencies (lock_api, parking_lot_core, optional serde for serialization support), platform-specific thread-parking backends under core/src/thread_parker/ for Unix, Windows, and wasm. Uses cfg-gated optional features (hardware-lock-elision, deadlock_detection, arc_lock, send_guard) rather than always-on complexity.

Code Quality — Test coverage leans on doctests and dedicated regression tests for specific historical bugs (tests/issue_203.rs, tests/issue_392.rs), plus CI that runs under Miri (ci/miri.sh) for undefined-behavior detection — an important signal of rigor for unsafe, low-level concurrency code. Activity has slowed to ‘moderate’ per GitHub metrics, consistent with a mature, largely feature-complete crate rather than one being actively rewritten.

API Design — The types are intentionally near-identical in shape to std::sync’s Mutex/RwLock, so migration is usually a matter of swapping the import; extras like raw locking without a RAII guard and atomic write-to-read downgrading are additive rather than disruptive to that familiar API. The one real learning-curve cost is understanding the optional feature flags (fairness, elision, deadlock detection) well enough to pick the right trade-offs, since each changes performance/behavior characteristics non-trivially.

Used by 17 apps in this directory

Rust
85%
AGPL 3.0

ParadeDB

Analytics · Databases · Search

9,436

Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.

View details
89
Repo Health
87
Technical
68
Dependency
Built with
Rust 85%
PLpgSQL 15%
Updated yesterday
Rust
63%
MIT

PostgresML

AI Development · Databases

6,823

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust 63%
JavaScript 11%
Updated 1 years ago
Rust
69%
AGPL 3.0

RustDesk

Networking

126,751

Open-source, self-hosted remote desktop built in Rust — your data, your infrastructure, no third-party cloud.

View details
93
Repo Health
84
Technical
70
Dependency
Built with
Rust 69%
Dart 22%
Updated yesterday
Rust
79%
AGPL 3.0

Spacedrive

Collaboration · File Storage

39,292

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
84
Repo Health
84
Technical
63
Dependency
Built with
Rust 79%
TypeScript 18%
Updated 1 weeks ago
Rust
98%

Stalwart

Collaboration

15,268

All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.

View details
88
Repo Health
81
Technical
65
Dependency
Built with
Rust 98%
Updated 5 days ago
Rust
66%
Apache 2.0

Temps

Analytics · Devops · Monitoring

865

A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.

View details
81
Repo Health
86
Technical
66
Dependency
Built with
Rust 66%
TypeScript 33%
Updated 2 days ago
Rust
97%
Apache 2.0

Volga

Data Engineering

161

A Rust-based real-time data processing engine for AI/ML feature computation, built on Apache DataFusion and Arrow — positioned as an alternative to Flink, Spark, Chronon, and OpenMLDB with unified streaming, batch, and request-time execution.

View details
61
Repo Health
67
Technical
72
Dependency
Built with
Rust 97%
Updated 4 weeks ago
Python
66%
Apache 2.0

WrenAI

AI Agents · Analytics · Data Engineering

17,958

Open-source GenBI engine that lets AI agents turn natural-language questions into governed SQL, charts, and shareable dashboards across 20+ data sources — no vendor lock-in, no black-box prompts.

View details
91
Repo Health
91
Technical
68
Dependency
Built with
Python 66%
Rust 31%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers