| Crates.io | rart |
| lib.rs | rart |
| version | 0.2.1 |
| created_at | 2025-07-29 02:55:05.797393+00 |
| updated_at | 2025-07-30 12:51:59.61129+00 |
| description | High-performance Adaptive Radix Tree implementation with SIMD optimizations |
| homepage | https://github.com/rdaum/rart-rs |
| repository | https://github.com/rdaum/rart-rs |
| max_upload_size | |
| id | 1771829 |
| size | 289,442 |
rart - Ryan's Adaptive Radix TreeA high-performance, memory-efficient implementation of Adaptive Radix Trees (ART) in Rust, with support for both single-threaded and versioned concurrent data structures.
This crate provides two high-performance tree implementations:
AdaptiveRadixTree - Single-threaded radix tree optimized for speedVersionedAdaptiveRadixTree - Thread-safe versioned tree with copy-on-write snapshots for
concurrent workloadsBoth trees automatically adjust their internal representation based on data density for ordered associative data structures.
Key Features:
Best for: Single-threaded applications.
use rart::{AdaptiveRadixTree, ArrayKey};
let mut tree = AdaptiveRadixTree::<ArrayKey<16 >, String>::new();
tree.insert("apple", "fruit".to_string());
tree.insert("application", "software".to_string());
assert_eq!(tree.get("apple"), Some(&"fruit".to_string()));
// Range queries and iteration
for (key, value) in tree.iter() {
println ! ("{:?} -> {}", key.as_ref(), value);
}
Key Features:
Best for: Concurrent versioned workloads, databases, multi-reader systems.
use rart::{VersionedAdaptiveRadixTree, ArrayKey};
let mut tree = VersionedAdaptiveRadixTree::<ArrayKey<16 >, String>::new();
tree.insert("key1", "value1".to_string());
// O(1) snapshot creation
let mut snapshot = tree.snapshot();
// Independent mutations
tree.insert("key2", "value2".to_string()); // Only in original
snapshot.insert("key3", "value3".to_string()); // Only in snapshot
assert_eq!(tree.get("key3"), None);
assert_eq!(snapshot.get("key2"), None);
assert_eq!(snapshot.get("key3"), Some(&"value3".to_string()));
Both trees support flexible key types optimized for different use cases:
ArrayKey<N>: Fixed-size keys up to N bytes, stack-allocated for performanceVectorKey: Variable-size keys, heap-allocated for flexibilityuse rart::{ArrayKey, VectorKey};
// Fixed-size keys (recommended for performance)
let key1: ArrayKey<16 > = "hello".into();
let key2: ArrayKey<8 > = 42u64.into();
// Variable-size keys (for dynamic content)
let key3: VectorKey = "hello world".into();
let key4: VectorKey = 1337u32.into();
Performance characteristics for sequential and random access patterns:
Sequential access:
Random access:
Optimized for transactional workloads with copy-on-write semantics:
Lookup Performance (vs persistent collections from the im crate):
Comparison against im::HashMap (HAMT) and im::OrdMap (B-tree), both persistent data structures with structural sharing:
Sequential Scanning:
Snapshot Operations:
Persistent Structure Trade-offs:
Best suited for: Read-heavy versioned workloads, database snapshots, concurrent systems requiring point-in-time consistency and efficient structural sharing.
📊 View Complete Performance Analysis - Detailed benchmarks, technical insights, and workload recommendations.
Benchmarks run on AMD Ryzen 9 7940HS using Criterion.rs
Both implementations use several key optimizations:
Additional for VersionedAdaptiveRadixTree:
Based on "The Adaptive Radix Tree: ARTful Indexing for Main-Memory Databases" by Viktor Leis, Alfons Kemper, and Thomas Neumann, with additional optimizations for Rust and versioning support.
Technical Details:
im crate collectionsFor detailed API documentation and examples, visit docs.rs/rart.
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Contributions are welcome! Please feel free to submit issues and pull requests.