Feature Flags
RotorTree provides a modular feature system allowing you to enable only the functionality you need. The core algorithm has zero dependencies by default.Quick Reference
blake3
Default. Provides
Blake3Hasher adapterstd
Standard library support (default via blake3)
concurrent
Thread-safe
&self methods with RwLockparallel
Rayon-parallelized batch insertions
storage
WAL persistence and checkpointing
wincode
Fast Solana-style serialization
serde
Standard serde serialization
test-helpers
Testing utilities (dev only)
Feature Combinations
Minimal (No Dependencies)
LeanIMTin-memory treeno_stdcompatible- Zero dependencies
- Bring your own hasher (implement
Hashertrait)
- Embedded systems
- WASM targets
- ZK circuits (with custom field-aware hasher)
- Minimal binary size
Default (Blake3 + std)
Blake3Hasheradapter- Standard library support
- In-memory
LeanIMTonly
blake3 (1 crate)
Best for:
- Most use cases
- Quick prototyping
- When you don’t need persistence
Concurrent (Thread-Safe)
LeanIMTmethods take&selfinstead of&mut self- Internal
RwLocksynchronization viaparking_lot - Multiple threads can hold snapshots while one thread inserts
blake3, parking_lot (5 crates total)
API Difference:
- ~5-10% overhead on single-threaded insertions
- Worthwhile if you need concurrent snapshots + insertions
Parallel (Rayon-Powered)
- Automatic parallelization of
insert_manyfor large batches - Uses rayon work-stealing for optimal CPU utilization
blake3, rayon (~15 crates total)
Behavior:
- Parallelism kicks in when parent count exceeds
ROTORTREE_PARALLEL_THRESHOLD(default: 1024) - Work is split into chunks of
PAR_CHUNK_SIZEparents (default: 64) - Linear speedup up to ~8 cores, then diminishing returns
- Single-threaded: ~1-2M leaves/sec
- Parallel (8 cores): ~10-20M leaves/sec
- Parallel (14 cores): ~190M leaves/sec peak
Storage (Persistence)
RotorTreetype with WAL persistence- Crash recovery via WAL replay
- Checkpointing to data files
- Memory-mapped storage tiers
- Durability tokens
parking_lot, arc-swap, fs4, memmap2, crc-fast, wincode)
API:
Serialization
Wincode (Solana-Style)
wincodederives onNaryProofandConsistencyProof- Compatible with Solana’s wincode format
- Fastest serialization option
The
storage feature automatically includes wincode since it’s used internally for WAL frames.Serde (Standard)
- Standard
serdederives on proof types - Compatible with
serde_json,bincode,postcard, etc. - Better ecosystem compatibility than wincode
You can enable both
wincode and serde simultaneously for maximum flexibility.Complete Feature Matrix
| Feature | Dependencies | Binary Size | Use Case |
|---|---|---|---|
default-features = false | 0 | Minimal | Embedded, WASM, ZK circuits |
blake3 (default) | 1 | +50 KB | Standard hashing |
std | via blake3 | +0 KB | Standard library support |
concurrent | +4 | +100 KB | Multi-threaded access |
parallel | +14 | +500 KB | Batch insertion speedup |
storage | +19 | +800 KB | Crash recovery |
wincode | +1 | +50 KB | Solana compatibility |
serde | +2 | +100 KB | Ecosystem serialization |
Binary sizes are approximate and include transitive dependencies. Actual size depends on target and optimization level.
Common Configurations
Web Application (High Throughput)
Blockchain Full Node
Light Client
ZK Circuit (Custom Field)
Hasher trait for field-aware hashing
Embedded System
no_std environment with custom hasher
Feature Dependencies
Some features automatically enable others:Enabling
storage automatically gives you std, wincode, and several other dependencies.Runtime Configuration
Some features expose runtime configuration:Parallel Threshold
insert_many. Higher values = less parallelism overhead for smaller batches.
Rayon Thread Pool
Compile-Time Constants
These require source modification and recompilation:| Constant | Default | Location | Effect |
|---|---|---|---|
CHUNK_SIZE | 128 | src/tree.rs | Hashes per chunk (affects snapshot cost) |
CHUNKS_PER_SEGMENT | 256 | src/tree.rs | Chunks per immutable segment |
PAR_CHUNK_SIZE | 64 | src/tree.rs | Parents per rayon work unit |
MAX_FRAME_PAYLOAD | 128 MB | src/storage/frame.rs | Max WAL frame size |
CHUNKS_PER_SHARD | 65,536 | src/storage/checkpoint.rs | Chunks per data file |
Feature Recommendations
I need crash recovery
I need crash recovery
Enable
storage feature:I'm building a web API
I'm building a web API
Enable
storage, parallel, and serde:I have multiple reader threads
I have multiple reader threads
Enable
concurrent feature:I want maximum throughput
I want maximum throughput
Enable
parallel and tune ROTORTREE_PARALLEL_THRESHOLD:I'm targeting WASM
I'm targeting WASM
Disable default features:Implement custom hasher if needed.
I need Solana compatibility
I need Solana compatibility
Enable
wincode feature:Next Steps
Performance Tuning
Optimize compile-time and runtime parameters
In-Memory Trees
Learn the basics of LeanIMT
Persistent Storage
Set up WAL-based persistence
Proof Generation
Generate and verify proofs
