Skip to content

Benchmarking different reed-solomon crates in rust, specifically for usage in Propeller

Notifications You must be signed in to change notification settings

sirandreww-starkware/reed-solomon-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reed-Solomon Benchmark Suite

A comprehensive benchmark comparing the performance of popular Rust Reed-Solomon erasure coding crates.

Benchmarked Crates

  • reed-solomon-erasure (v6.0) - Most widely used, mature implementation
  • reed-solomon-novelpoly (v2.0) - Performance-focused with novel polynomial basis
  • reed-solomon-16 (v0.1) - Optimized for 16-bit operations
  • reed-solomon-simd (v3.1) - SIMD-optimized implementation with O(n log n) complexity

Test Configuration

Shard Configurations (F data + 2F coding)

The benchmarks test with the following configurations, where F is the number of data shards:

  • F=1: 1 data + 2 coding shards (3 total)
  • F=2: 2 data + 4 coding shards (6 total)
  • F=3: 3 data + 6 coding shards (9 total)
  • F=4: 4 data + 8 coding shards (12 total)
  • F=5: 5 data + 10 coding shards (15 total)
  • F=10: 10 data + 20 coding shards (30 total)
  • F=20: 20 data + 40 coding shards (60 total)
  • F=30: 30 data + 60 coding shards (90 total)
  • F=33: 33 data + 66 coding shards (99 total)

This provides 2x redundancy - you can lose up to 2F shards and still recover the original data.

Data Sizes

Each configuration is tested with the following data sizes:

  • 256KB
  • 512KB
  • 1MB

Note: The full benchmark suite supports 1KB through 100MB, but for practical testing, a subset of sizes is used. Edit benches/common/mod.rs to enable all data sizes.

Operations Benchmarked

  1. Encoding: Splitting data into shards and generating parity shards
  2. Decoding: Reconstructing original data from partial shards
    • With 1 missing shard
    • With F missing shards
    • With 2F missing shards (maximum recoverable)
  3. Verification: Checking data integrity without full decode

Running the Benchmarks

Prerequisites

# Ensure you have Rust installed
rustup update

Run All Benchmarks

# Run all benchmarks
cargo bench

# Run specific benchmark suite
cargo bench --bench encode
cargo bench --bench decode
cargo bench --bench verify

Run Specific Tests

# Run only encoding benchmarks for reed-solomon-erasure
cargo bench --bench encode encode_erasure

# Run only decoding benchmarks for reed-solomon-novelpoly
cargo bench --bench decode decode_novelpoly

# Run verification for reed-solomon-16
cargo bench --bench verify verify_rs16

Filter by Configuration

# Run benchmarks for a specific F value
cargo bench -- F10

# Run benchmarks for a specific data size
cargo bench -- 1MB

# Run benchmarks for specific crate
cargo bench -- erasure

Understanding the Results

Divan outputs detailed statistics for each benchmark:

  • Time: Mean execution time with standard deviation
  • Throughput: Data processed per second (for applicable benchmarks)
  • Comparison: Relative performance between different implementations

Key Metrics to Consider

  1. Encoding Speed: How fast can data be split and parity generated?
  2. Decoding Speed: How fast can missing data be reconstructed?
  3. Scalability: How does performance change with:
    • Increasing data size
    • Increasing number of shards (F value)
    • Increasing number of missing shards

Expected Performance Characteristics

  • Small F values (1-5): Lower overhead, faster for small data
  • Large F values (20-33): Better parallelization potential, more efficient for large data
  • Encoding: Generally faster than decoding
  • Decoding: Slower with more missing shards (more computation needed)

Benchmark Results Summary

Based on comprehensive testing across multiple configurations:

Performance Ranking (Decode Performance, 1MB data)

  1. 🥇 reed-solomon-simd - FASTEST (0.7ms - 2.8ms)

    • 10-30x faster than alternatives
    • Excellent scaling with more missing shards
    • Hardware-accelerated SIMD instructions
    • Recommended for most use cases
  2. 🥈 reed-solomon-erasure - Good (1.1ms - 30ms)

    • Very fast for simple cases (1-2 missing shards)
    • Performance degrades with many missing shards
    • Most mature and battle-tested
    • Good fallback if SIMD unavailable
  3. 🥉 reed-solomon-16 - Moderate (3ms - 23ms)

    • 3-10x slower than simd
    • Consistent performance
    • Uses 16-bit operations
  4. reed-solomon-novelpoly - Slowest (25ms - 60ms)

    • 10-30x slower than simd
    • Novel polynomial basis doesn't translate to speed
    • Not recommended for performance-critical applications

When to Use Each Crate

reed-solomon-simdRECOMMENDED:

  • ✅ Best performance across all configurations
  • ✅ O(n log n) complexity using FFT-based algorithms
  • ✅ Leverages SIMD instructions (SSE, AVX2, NEON)
  • ✅ Scales beautifully with increasing complexity
  • Use unless you have a specific reason not to

reed-solomon-erasure:

  • Most mature and widely tested
  • Good for simple cases with few missing shards
  • Comprehensive API with verification support
  • Use if SIMD is unavailable or for maximum compatibility

reed-solomon-16:

  • Uses 16-bit operations instead of 8-bit
  • Moderate performance
  • Different memory characteristics
  • Limited use cases

reed-solomon-novelpoly:

  • Novel polynomial basis implementation
  • Slowest performance in benchmarks
  • Not recommended unless you need specific features

Hardware Specifications

Record your hardware specifications when running benchmarks:

# Linux
lscpu
free -h

# macOS
sysctl -n machdep.cpu.brand_string
sysctl hw.memsize

# Windows
wmic cpu get name
wmic computersystem get totalphysicalmemory

Viewing Results

Divan outputs results directly to the terminal with detailed statistics including:

  • Fastest, slowest, median, and mean execution times
  • Number of samples and iterations
  • Easy-to-read tree format showing all configurations

Example output:

decode_simd
├─ decode_1_missing
│  ├─ BenchConfig { f: 10, data_size: 1048576 }  1.587 ms  │ 5.702 ms  │ 1.739 ms  │ 1.925 ms  │ 100  │ 100

Contributing

To add a new Reed-Solomon crate to the benchmark:

  1. Add the crate to Cargo.toml dependencies
  2. Create a new benchmark group in each of encode.rs, decode.rs, and verify.rs
  3. Follow the existing pattern for consistency
  4. Update this README with the new crate information

License

This benchmark suite is provided as-is for performance comparison purposes.

Notes

  • Benchmarks use deterministic data generation for reproducibility
  • Each benchmark is run multiple times to ensure statistical significance
  • Results may vary based on hardware, OS, and system load
  • For production use, always test with your specific use case and data patterns

About

Benchmarking different reed-solomon crates in rust, specifically for usage in Propeller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages