turbosort — SIMD-accelerated radix sort for primitives in Rust
Just published my first crate and wanted to share it with the community.
turbosort is an adaptive sorting library for all 10 primitive numeric types.
Benchmarks (10M random u32):
- std::sort_unstable: 301ms
- turbosort::sort: 182ms (1.7x faster)
- At 1M elements the gap is 3.1x
The key idea is tiered algorithm dispatch based on input size:
- 0–1: no-op
- 2–16: SIMD sorting networks (AVX2, NEON ≤8)
- 17–512: quicksort with SIMD leaf nodes
- 513+: LSD radix sort
- 131K+: parallel radix sort via rayon
SIMD support:
- x86_64: AVX2 with runtime CPUID dispatch (same binary works on all CPUs)
- aarch64: NEON sorting networks (4-lane)
- Scalar fallback for everything else
Also supports no_std — disable default features and use sort_with_buffer() with a caller-provided buffer for zero-allocation sorting.
Float sorting uses total ordering: -inf < -0.0 < +0.0 < +inf < NaN.
Would love feedback on the approach, especially around the SIMD sorting network implementation and the dispatch thresholds. The crossover points were chosen empirically but I'm curious if others have found different sweet spots.
https://github.com/ampactor-labs/turbosort
https://crates.io/crates/turbosort
Dual-licensed MIT/Apache-2.0.