ArcSwap

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
45 /100 Fair
Development Activity 24
Maintenance 8
Community 48
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 80
Code Quality 84
Innovation 78
Learning Curve 66

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 9 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

AI Assistants · Collaboration · Productivity

76,967

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
67
Dependency
Built with
Dart 74%
Rust 24%
Updated 1 weeks ago
Rust
86%
Other

Arroyo

Analytics · Data Engineering

5,039

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
Rust 86%
Updated 1 weeks ago
Go
32%
Apache 2.0

CubeSandbox

AI Agents · Developer Tools · Security

12,728

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
82
Repo Health
88
Technical
63
Dependency
Built with
Go 32%
Rust 26%
C 22%
Updated 1 weeks ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,285

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
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 5 days ago
Rust
85%
Apache 2.0

OpenShell

AI Agents · Developer Tools

8,811

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
85
Repo Health
81
Technical
68
Dependency
Built with
Rust 85%
Updated 4 days ago
Rust
90%
Apache 2.0

Qdrant

AI Development · Databases · Search

34,857

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
65
Dependency
Built with
Rust 90%
Updated 5 days ago
Rust
98%

Stalwart

Collaboration

14,848

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
65
Dependency
Built with
Rust 98%
Updated 5 days ago
Rust
64%
Apache 2.0

Temps

Analytics · Devops · Monitoring

801

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
70
Dependency
Built with
Rust 64%
TypeScript 34%
Updated 4 days ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,717

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
69
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 3 months 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