ArcSwap

Lock-free atomically swappable Arc for Rust read-mostly workloads

Library
Cargo
v1.9.2
1,403stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity40
Maintenance16
Community48
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture80
Code Quality84
Innovation78
Learning Curve66

arc-swap provides ArcSwap, a container that makes an Arc<T> itself atomically swappable — semantically similar to Atomic<Arc<T>> or RwLock<Arc<T>> but without needing a lock, and optimized for read-mostly, write-seldom workloads with consistent, predictable performance under contention.

It targets scenarios like live configuration reloads, routing-table updates, and periodic data-structure snapshots, where many threads need to read a shared value frequently and concurrently while updates happen rarely, and where a naive RwLock<Arc<T>> suffers from lock and reference-count contention.

What You Get

  • ArcSwap<T> — lock-free atomic container for swapping an Arc<T> across threads
  • ArcSwapOption/ArcSwapWeak variants for optional and weak-reference use cases (behind the weak feature)
  • A Cache type for amortizing the cost of repeated loads on a single thread
  • Optional serde (de)serialization support behind a feature flag
  • no_std support via an experimental thread-local feature flag for constrained environments
  • Configurable internal strategies exposed for advanced/experimental tuning (not part of the stable API surface)

Common Use Cases

  • Hot-reloading application configuration without pausing request processing on every read
  • Sharing an up-to-date routing table or feature-flag snapshot across many worker threads with minimal read overhead
  • Replacing RwLock<Arc<T>> in read-heavy, low-write concurrent data structures to reduce lock contention
  • Building lock-free caches or snapshot-style shared state where readers must never block on a writer

Under The Hood

Architecture — The crate’s public surface centers on ArcSwap defined in src/lib.rs, backed by pluggable internal strategy implementations (src/strategy/) that implement the actual atomic-swap algorithm, a debt module implementing a hazard-pointer-like reference-counting scheme to safely reclaim old Arc allocations without blocking readers, and access.rs/cache.rs providing higher-level access patterns (like the Cache type for per-thread load amortization). ref_cnt.rs and as_raw.rs abstract over reference-counted types so the same machinery can support Arc, Rc-like, and weak-reference variants.

Tech Stack — Pure Rust, edition 2018, with rustversion as its only mandatory dependency (used to gate version-specific code paths) and serde as an optional feature. Dev-dependencies include criterion for benchmarking (three benchmark suites: background, int-access, track), proptest for property-based testing, and loom-adjacent concurrency testing tools like crossbeam-utils and adaptive-barrier to validate lock-free correctness under concurrent execution.

Code Quality — The crate carries #![warn(missing_docs)] and denies warnings in doctests (#![doc(test(attr(deny(warnings))))]), and includes compile_fail_tests.rs to assert that certain misuse patterns fail to compile. With Codecov integration, a dedicated docs/ folder of internal design documentation, and proptest-based property tests alongside criterion benchmarks, the project treats correctness of its lock-free algorithm as the primary quality bar — appropriate given the subtlety of writing sound concurrent/atomic code.

API Design — The type mirrors familiar Arc/RwLock ergonomics (ArcSwap::from_pointee, .load(), .store()) so Rust developers already familiar with Arc and locking primitives can adopt it with minimal new concepts, while advanced users can reach for Cache or the access module for further tuning. Experimental strategies and thread-local no_std support are explicitly marked without stability guarantees, keeping the stable API small and well-scoped.

Used by 7 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
Rust
86%
Other

Arroyo

Data Engineering · Analytics

5,005

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust86%
Updated 1 weeks ago
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today
TypeScript
69%
Apache 2.0

Laminar

AI Development · Monitoring

3,180

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
70
Dependency
Built with
TypeScript69%
Rust29%
Updated yesterday
Rust
84%
Apache 2.0

OpenShell

AI Agents · Developer Tools

8,270

The safe, private runtime that lets autonomous AI agents operate in sandboxed environments governed by declarative YAML policies — blocking data exfiltration, credential leaks, and unauthorized network activity before they happen.

View details
84
Repo Health
81
Technical
69
Dependency
Built with
Rust84%
Updated today
Rust
89%
Apache 2.0

Qdrant

Databases · AI Development · Search

34,058

Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.

View details
92
Repo Health
87
Technical
69
Dependency
Built with
Rust89%
Updated yesterday
Rust
98%

Stalwart

Collaboration

14,255

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
89
Repo Health
81
Technical
68
Dependency
Built with
Rust98%
Updated yesterday

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

Search