Show HN: Glidesort, a new stable sort in Rust up to ~4x faster for random data (opens in a new tab)github.com
389 pointsHi all, I've talked about glidesort a few times on HN already, but it's finally ready for release. If you have any questions, feel free to ask. An academic paper on glidesort that goes into a lot more detail than the readme is upcoming, but is not ready yet.
I will be giving a talk on glidesort tomorrow at FOSDEM 2023 in the Rust Devroom at 16:10, you can seek me out there as well. In other news, I am leaving academia soon, so if you have interesting (Rust) jobs the coming months feel free to approach me.
Comments (70) 12 threads
Show all comments
Showing thread 1 of 12
Commands to run to replicate my results are below. Clone rhsort and run them in that directory. The res/*.txt results are human-readable but you have to install my programming language[2] to generate the plot. Hey, you made me program in Rust.
[0] https://gist.github.com/mlochbaum/7664a046d294dcce2f6cdb1db6...
[1] https://github.com/mlochbaum/rhsort
[2] https://github.com/mlochbaum/BQN
Also when you say x86, I assume you mean x86-64? I have not tested raw x86. What is your actual processor?
EDIT 2: I believe this should also go in the Cargo.toml of glide in your repository, not in a .cargo/config
Does panic safety really cost 10-15% when sorting integers according to default comparison?
Either way, I am not surprised that glidesort is a bit slower than fluxsort on older machines. They're less likely to take advantage of the interleaving techniques I use.
> Does panic safety really cost 10-15% when sorting integers according to default comparison?
Yes :(
At least yes, if you don't want to duplicate your entire codebase. Look into the code of glidesort if you want to, all algorithm state has to be encoded inside structs at all times, to allow for recovery in case a comparator panics using the destructor.
This negatively affects the optimizer for reasons I can't fully explain compared to having the state be in simple local variables.
Orson: https://matrix.org/_matrix/media/r0/download/matrix.org/ldcd...
i3-4160: https://matrix.org/_matrix/media/r0/download/matrix.org/OBwS...
(edit) i5-6200U update: https://matrix.org/_matrix/media/r0/download/matrix.org/vzDr...
M2: https://matrix.org/_matrix/media/r0/download/matrix.org/ZRTj...
Continue this thread — 5 replies
Continue this thread — 4 replies
I'm not surprised fluxsort is slightly faster, it's heavily optimized for gcc -O3.
Since the primary techniques that give glidesort it's speed were copied from fluxsort and quadsort I'm expecting very similar performance, and possibly significantly worse performance on strings due to accessing 4 memory regions.
Have you gotten it working with the wolfsort benchmark?
I was planning to update my repository to grab the appropriate files from the fluxsort repository but if you'd update the wolfsort repo I wouldn't have to. Although maybe I should switch over to cloning fluxsort instead.
The latest fluxsort is probably identical on random, the new analyzer might perform slightly better on modern hardware.
Probably safer to stick with wolfsort as I do tend to make sure that works with rhsort when I update.
Continue this thread — 6 replies