Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Performance Documentation

This document contains performance benchmarks for the ApexStore LSM-tree storage engine.

Latest CI results

The block below is rewritten by the nightly Benchmarks workflow. Do not edit it by hand -- edits are overwritten. The workflow commits only when the numbers actually change, and fails rather than publishing an empty table.

Auto-updated by CI on 2026-11-04 19:07 UTC — view run Runner: Linux (GitHub-hosted). Commit: c296bafb929007538cadca01733dcc55bef590cf.

📝 Write

BenchmarkMedianPerf
write_single/1054.988 µs🟡
write_single/102478.811 µs🟡
write_batch_1000/100060.063 ms🟠
write_batch_10000/10000566.64 ms🔴
memtable_flush_8/877.598 ms🟠
sstable_flush/1000016.061 ms🟠
write_size_10_100/10x10055.937 µs🟡
write_size_100_10000/100x10000111.04 µs🟡
key_updates/10k_keys574.88 ms🔴
delete_operations/10k_keys565.75 ms🔴

📚 Read

BenchmarkMedianPerf
read_memtable/1000248.38 µs🟡
read_memtable/10000252.68 µs🟡
read_sstable_cold/1000477.10 µs🟡
read_sstable_cold/10000494.09 µs🟡
read_sstable_warm/1000472.70 µs🟡
read_sstable_warm/10000593.73 µs🟡
read_latency/memtable_1k228.93 µs🟡
read_latency/sstable_cold_1k475.33 µs🟡
read_memtable_latency/memtable_1k229.23 µs🟡
read_sstable_warm_latency/sstable_warm_1k477.71 µs🟡
read_latency_memtable_1k/memtable_1k251.54 µs🟡
read_latency_memtable_100k/memtable_100k40.737 ms🟠
read_latency_sstable_1k/sstable_warm_1k427.83 µs🟡
read_latency_sstable_100k/sstable_warm_100k183.27 ms🔴

🔍 Scan

BenchmarkMedianPerf
scan_sequential/1000552.06 µs🟡
scan_sequential/100007.0201 ms🟠
full_scan/1000497.46 µs🟡
full_scan/100006.4072 ms🟠
range_scan_100/1004.7535 ms🟠
prefix_scan_100/1004.9135 ms🟠
prefix_scan_1000/10004.8718 ms🟠
iteration_sorted/1000529.71 µs🟡
iteration_sorted/100006.3805 ms🟠
scan_limit_10/104.0680 ms🟠
scan_limit_100/1004.0798 ms🟠
scan_pagination/1041.270 ms🟠
scan_pagination/100471.33 ms🔴

🌐 YCSB

BenchmarkMedianPerf
ycsb_type_a/1000029.266 ms🟠
ycsb_type_b/100004.0192 ms🟠
ycsb_type_c/10000747.09 µs🟡
ycsb_type_c/1000002.1759 ms🟠

⚡ Mixed Workload

BenchmarkMedianPerf
workload_balanced/1000029.922 ms🟠
workload_read_heavy/100006.8636 ms🟠
workload_write_heavy/1000052.849 ms🟠

🏗️ SSTable

BenchmarkMedianPerf
sstable_layer_1/15.9463 ms🟠
many_sstables_10/10547.72 µs🟡

🧵 Bloom Filter

BenchmarkMedianPerf
bloom_filter/100009.4871 ms🟠

💾 Cache

BenchmarkMedianPerf
cache_thrash_64MB/6494.968 µs🟡

🧵 Concurrency

BenchmarkMedianPerf
concurrent_1_threads/13.4724 ms🟠

💡 Memory

BenchmarkMedianPerf
memory_pressure/small_memtable264.05 µs🟡

⚙️ Other

BenchmarkMedianPerf
read_negative_bloom/negative_bloom_10k928.85 µs🟡
scan_1000_keys/scan_1k543.82 µs🟡
write_latency_1k/write_1k91.730 ms🟠
write_latency_100k/write_100k10.860 s🔴
write_amplification_leveled/leveled_10k_keys766.90 ms🔴
write_amplification_size_tiered/size_tiered_10k_keys796.34 ms🔴

Run them locally with make bench, or cargo bench --all-features for HTML reports under target/criterion/.

Benchmarks Overview

The benchmark suite is located in benches/ and covers the following categories:

Write Benchmarks (benches/write_bench.rs)

  • Single Write: Latency for individual write operations with varying key/value sizes (10B to 100KB)
  • Batch Write: Throughput for batch insertions (1K, 10K, 100K operations)
  • Memtable Flush: Performance impact of flush operations (8MB, 16MB, 32MB)
  • SSTable Flush: Write throughput during SSTable creation

Read Benchmarks (benches/read_bench.rs)

  • MemTable Reads: Read latency when keys are in-memory (expected: ~1M ops/sec)
  • SSTable Reads (Cold): Read latency from disk with no cache
  • SSTable Reads (Warm): Read latency with cached data
  • Bloom Filter: False positive rate and lookup speed
  • Sequential Scan: Full scan throughput

Mixed Workloads (benches/mixed_bench.rs)

  • YCSB Type A: 50% read, 50% write (uniform)
  • YCSB Type B: 95% read, 5% write (read-heavy)
  • YCSB Type C: 100% read (read-only)
  • Balanced: 50/50 read/write
  • Read-Heavy: 90% read, 10% write
  • Write-Heavy: 10% read, 90% write

Scan Benchmarks (benches/scan_bench.rs)

  • Full Scan: Complete dataset iteration
  • Range Scan: Indexed range queries (100 to 100K keys)
  • Prefix Scan: Hierarchical key queries
  • Pagination: Cursor-based pagination performance
  • SSTable Layers: Performance with increasing SSTable counts (1 to 30 layers)

Stress Benchmarks (benches/stress_bench.rs)

  • Large Dataset: 1M keys with concurrent access
  • Concurrent Access: 1, 2, 4 threads reading/writing
  • Memory Pressure: Small memtable (2MB) forcing frequent flushes
  • Many SSTables: 10, 50, 100 SSTables
  • Cache Thrashing: Different cache sizes (16, 64, 128MB)
  • Key Updates: Update operations on existing keys
  • Delete Operations: Tombstone creation and cleanup

Expected Performance Targets

Write Performance

OperationExpected Throughput
MemTable Only500K-1M ops/sec
With WAL (async)100K-200K ops/sec
With WAL (fsync)5K-10K ops/sec
Batch (1K ops)500K-1M ops/sec

Read Performance

OperationExpected Throughput
MemTable Hits800K-1M ops/sec
SSTable (warm cache)50K-100K ops/sec
SSTable (cold cache)5K-10K ops/sec

Scan Performance

OperationExpected Throughput
Full Scan10M-20M keys/sec
Range Scan5M-10M keys/sec

Configuration Parameters

The benchmark suite allows tuning the following parameters:

#![allow(unused)]
fn main() {
pub struct BenchmarkConfig {
    pub key_size: usize,          // Key size in bytes
    pub value_size: usize,        // Value size in bytes
    pub num_keys: usize,          // Number of keys in dataset
    pub memtable_max_size: usize, // MemTable size before flush
    pub block_cache_size_mb: usize, // Block cache size in MB
    pub bloom_false_positive_rate: f64, // Bloom filter FP rate
    pub sparse_index_interval: usize,   // Sparse index interval
}
}

Running Benchmarks

Local Execution

# Run all benchmarks
cargo bench --all-features

# Run specific benchmark category
cargo bench --bench write_bench
cargo bench --bench read_bench
cargo bench --bench mixed_bench
cargo bench --bench scan_bench
cargo bench --bench stress_bench

# Generate HTML reports
cargo bench --all-features -- --output-format html

CI Execution

Run with the cargo-hack tool for comprehensive testing:

cargo hack bench --feature-powerset

Measuring Results

Latency Metrics

  • p50 (Median): 50% of operations complete within this time
  • p99: 99% of operations complete within this time
  • p999: 99.9% of operations complete within this time

Throughput Metrics

  • Operations per second: Total operations / total time
  • Bytes per second: Total bytes processed / total time
  • Keys per second: Keys scanned / total time (for scans)

Analysis Guidelines

  1. Baseline Establishment: Run benchmarks on clean repository before making changes
  2. Regression Detection: Alert on performance degradation > 10%
  3. Optimization Validation: Compare before/after for proposed improvements
  4. Configuration Tuning: Test different LsmConfig values for optimal performance

Results Interpretation

Good Performance Indicators

  • Low latency variance (consistent p99 close to p50)
  • High cache hit rates (> 80% for warm reads)
  • Efficient Bloom filter rejection (> 99% for non-existent keys)
  • Linear scaling with cache size

Warning Signs

  • High false positive rates (> 5% for Bloom filter)
  • Cache thrashing (throughput drops with more data)
  • Degradation with more SSTables (exponential growth in lookup time)
  • Memory pressure causing excessive GC/flush overhead

Future Benchmark Additions

  1. Compression Ratios: Measure LZ4 compression efficiency
  2. Compaction Performance: Size-tiered vs leveled compaction
  3. Replication Overhead: Network and sync costs
  4. Long-term Decay: Performance after extended operation

Configuration Impact on Performance

Memory Configuration

memtable_max_size

SizeWrite Throughput (async)Write Throughput (fsync)Best For
2 MB180K ops/s12K ops/sLow memory, high durability
8 MB420K ops/s8.5K ops/sBalanced workloads
16 MB650K ops/s7.5K ops/sDefault / Production
32 MB580K ops/s6.2K ops/sVery high write throughput
64 MB480K ops/s5.1K ops/sMemory-rich environments

Trade-off: Larger memtables improve write throughput but increase recovery time on crash.

block_cache_size_mb

Cache SizeWarm Read LatencyCold Read ThroughputMemory Usage
16 MB45.2 µs18K ops/sec16 MB
64 MB22.1 µs35K ops/sec64 MB
128 MB15.8 µs52K ops/sec128 MB
256 MB12.3 µs68K ops/sec256 MB
512 MB10.8 µs75K ops/sec512 MB

Recommendation: Set cache to 2-4x working dataset size for optimal performance.

bloom_false_positive_rate

RateMemory OverheadLookup EfficiencyBest Use Case
0.001 (0.1%)22 bits/entry99.2% rejectionMemory-constrained
0.01 (1%)11 bits/entry98.7% rejectionDefault
0.1 (10%)7 bits/entry95.3% rejectionExtreme memory limits

Disk I/O Configuration

sparse_index_interval

IntervalIndex SizeLookup SpeedBest For
8LargeFastestRead-heavy workloads
16MediumBalancedDefault
32SmallSlowerWrite-heavy workloads
64Very SmallSlowestHigh-throughput writes

Workload-Specific Recommendations

Write-Heavy (ingestion pipelines)

#![allow(unused)]
fn main() {
LsmConfig {
    core: CoreConfig {
        memtable_max_size: 32 * 1024 * 1024,  // 32MB
    },
    storage: StorageConfig {
        block_cache_size_mb: 128,  // Smaller cache
        bloom_false_positive_rate: 0.1,  // Reduce memory
        sparse_index_interval: 32,  // Smaller index
    },
}
}

Read-Heavy (serving applications)

#![allow(unused)]
fn main() {
LsmConfig {
    core: CoreConfig {
        memtable_max_size: 16 * 1024 * 1024,  // 16MB
    },
    storage: StorageConfig {
        block_cache_size_mb: 512,  // Large cache
        bloom_false_positive_rate: 0.001,  // Tighter Bloom filter
        sparse_index_interval: 8,  // denser index
    },
}
}

Balanced (general purpose)

#![allow(unused)]
fn main() {
LsmConfig {
    core: CoreConfig {
        memtable_max_size: 16 * 1024 * 1024,  // 16MB
    },
    storage: StorageConfig {
        block_cache_size_mb: 256,  // 256MB
        bloom_false_positive_rate: 0.01,  // Balanced
        sparse_index_interval: 16,  // Balanced
    },
}
}

Tuning Methodology

  1. Establish Baseline: Run benchmarks on current configuration
  2. Identify Bottleneck: Check CPU, memory, I/O utilization during peak load
  3. Change One Variable: Adjust a single config parameter
  4. Run Full Benchmark Suite: All categories to check for regressions
  5. Validate Over Time: Run for at least 30 minutes to catch gradual degradation
  6. Document Trade-offs: Note any performance gains vs other metrics

Performance Optimization Checklist

  • Enable LTO: [profile.release] opt-level = 3, lto = true
  • Use WAL_SYNC_MODE=async for write-heavy workloads
  • Cache size >= 2x working dataset size
  • Adjust memtable size to balance memory vs recovery time
  • Monitor Bloom filter false positive rate (should be < 2%)
  • Verify sparse index doesn't bloat SSTable files
  • Profile with perf or flamegraph for hot paths
  • Run benchmarks on production-like hardware

Contributing Performance Improvements

When proposing performance optimizations:

  1. Add benchmarks demonstrating the improvement
  2. Include before/after comparison
  3. Verify no regressions in other metrics
  4. Document the optimization and its trade-offs