Sorting Performance Rabbit Hole
4 days ago
- #algorithm optimization
- #sorting algorithms
- #performance benchmark
- Pystd's stable sort was optimized to be 5% faster than stdlibc++.
- Unstable sort required extensive tweaks, with the biggest improvement coming from changing the insertion sort limit from 16 to 32 elements.
- Despite various attempts like using memmove and different pivot selection, only adjusting the insertion sort threshold significantly boosted performance.
- Pystd's unstable sort finally matched stdlibc++'s speed with a best time of 0.754 seconds versus 0.755 seconds.