Compile-Time Constants
These constants are defined insrc/tree.rs and require modifying the source code and recompiling to change.
CHUNK_SIZE
128 × 32 bytes = 4 KBper chunk- Affects snapshot copy cost (larger chunks = fewer Arc clones)
- Controls Arc granularity for copy-on-write operations
- 4 KB aligns well with typical memory page sizes
- Increase for workloads with frequent snapshots and large trees
- Decrease if memory pressure is high or working with many small trees
CHUNKS_PER_SEGMENT
- Controls how many chunks are frozen into a single Arc slab
256 chunks × 128 hashes × 32 bytes = 1 MBper segment- Affects structural sharing granularity at a higher level than CHUNK_SIZE
- Increase for better batch operation performance on large datasets
- Decrease to reduce memory footprint per segment
PAR_CHUNK_SIZE
- Smaller values = more parallelism but higher scheduling overhead
- Larger values = less overhead but coarser parallelism
- Default
64balances work distribution and overhead
- Decrease on systems with many CPU cores (32+) for finer work distribution
- Increase on systems with fewer cores or high context-switching costs
- Benchmark with your specific hardware and batch sizes
Requires the
parallel feature to be enabled.MAX_FRAME_PAYLOAD
- Limits the size of a single
insert_manybatch that can be persisted 128 MB ÷ 32 bytes = 4,194,304leaves per batch maximum- Prevents unbounded memory usage during serialization
- Increase if you need to insert more than 4M leaves in a single batch
- Decrease to reduce memory spikes during WAL writes
Runtime Environment Variables
ROTORTREE_PARALLEL_THRESHOLD
1024
Feature: Requires the parallel feature
Minimum parent count before Rayon parallelism kicks in during insert_many operations.
Impact:
- Below this threshold: sequential processing (lower overhead)
- At or above: parallel processing with Rayon (higher throughput)
- Prevents parallelization overhead on small batches
Type Parameters
The tree structure itself is controlled by const generic parameters:N (Branching Factor)
Must be>= 2. Controls the tree width.
Common values: 2, 4, 8, 16
See Branching Factor for detailed guidance.
MAX_DEPTH
Must be>= 1. Controls the maximum tree depth.
Determines maximum capacity: N^MAX_DEPTH leaves
See Branching Factor for capacity calculations.
