Concurrent AVL Tree
Lock-free readable AVL tree with epoch-based memory reclamation and background batch rebalancing. Designed for high-concurrency, high-read workloads with deterministic traversal latency.
Table of Contents
- Features
- Installation
- Quick Start
- Architecture Overview
- Benchmarking & Testing
- Contributing & Changelog
- License
Features
- Lock-Free Reads
Readers traverse without acquiring mutexes or spinlocks. - Epoch-Based Reclamation
Zero use-after-free guarantees via deferred memory disposal. - Batched Rebuilds
Writes are collected, sorted, and applied by a background thread that atomically swaps the root pointer. - Generational Arena
Double-buffered, cache-line aligned allocator eliminates dynamic allocation during rebuilds. - Production-Ready Documentation
Strictrustdoccompliance, exhaustive examples, and CI-enforced lints.
Installation
Add to Cargo.toml:
[]
= "0.1.0"
Or via CLI:
Requires Rust 1.91.1 or newer.
Quick Start
use ConcurrentAVLTree;
Architecture Overview
┌─────────────┐ ┌──────────────┐ ┌───────────────────┐
│ Writers │──────▶│ Batch Queue │──────▶│ Background Thread │
└─────────────┘ └──────────────┘ └─────────┬─────────┘
│
▼
┌─────────────┐ ┌──────────────┐ ┌───────────────────┐
│ Readers │◀──────│ Root Pointer │◀──────│ Arena Swap │
└─────────────┘ └──────────────┘ └───────────────────┘
- Append Phase
Writers pushBatchEntryto a mutex-protected collector. - Rebuild Phase
Background thread extracts, sorts, and constructs a new AVL tree in the inactive arena buffer. - Swap Phase
RootAtomicPtris exchanged. Previous root is queued for epoch-based disposal. - Reclaim Phase
EBR tracks active reader epochs. After a two-epoch grace period, queued callbacks free memory safely.
Benchmarking & Testing
Run unit & doc tests:
Execute benchmarks (headless safe):
Generate coverage report:
Contributing & Changelog
- See CONTRIBUTING.md for setup, code style, and PR workflow.
- View release history in CHANGELOG.md.
License
SPDX-License-Identifier: MIT
© 2026 Dzulkifli Anwar
See LICENSE for full terms.