crumsort-rs

August 18, 2022 ยท View on GitHub

A parallelized Rust port of crumsort.

The goal of this port is to excel at sorting well-distributed data which is why it is not an exact 1:1 replica.

Temporary caveats

There are a few limitations given some of the constraints when this was originally written:

  • sorts uniform data faster than crumsort, but severly skewed distributions slower (missing crumsort_analyze function)
  • intended as a solution for sorting large (u64 or u128) integers
  • only sorts Copy + Default data as a way to limit the use of unsafe
  • missing un-parallelized version (data needs to implement Send)
  • missing *_by and *_by_key sorting alternatives (data needs to implement Ord)

Please feel free to submit improvements in any of these area by submitting a pull request.

Benchmarks against parallel pdqsort (Rayon)

All banchmarks run with the bench example on an M1 Pro:

cargo run --release --example bench

Uniformly distributed random u32s

LengthAlgorithmThroughputImprovement
212pdqsort32.15Mkeys/s0.00%
212crumsort38.70Mkeys/s20.39%
216pdqsort129.96Mkeys/s0.00%
216crumsort176.95Mkeys/s36.16%
220pdqsort226.31Mkeys/s0.00%
220crumsort368.09Mkeys/s62.65%
224pdqsort227.80Mkeys/s0.00%
224crumsort399.89Mkeys/s75.54%

Uniformly distributed random u64s

LengthAlgorithmThroughputImprovement
212pdqsort33.18Mkeys/s0.00%
212crumsort40.79Mkeys/s22.91%
216pdqsort151.24Mkeys/s0.00%
216crumsort237.48Mkeys/s57.02%
220pdqsort218.64Mkeys/s0.00%
220crumsort364.79Mkeys/s66.85%
224pdqsort226.83Mkeys/s0.00%
224crumsort385.42Mkeys/s69.92%

Note

This is not an officially supported Google product.