4 ms·
Try running with the latest nightly Rust (`rustup update nightly`) and with `cargo +nightly build --release`. EDIT: I'm sorry, you need to specify this in your
by orlp 4y ago
Try running with the latest nightly Rust (`rustup update nightly`) and with `cargo +nightly build --release`. EDIT: I'm sorry, you need to specify this in your Cargo.toml, my earlier command was incorrect:
glidesort = { version = "0.1.1", features = ["unstable"] }
To get the best performance I use specialization for Copy types (such as integers) to compete with the assumptions that fluxsort and such can make, which is not available on stable Rust (unless glidesort were to be merged into the standard library). Without that I have to be more conservative with bounds checks. And even then there's a variety of places where I sacrifice performance compared to fluxsort and such in the name of safety, and the limitations that Rust gives me (in particular panic safety has cost me 10-15% performance).
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
[profile.release]
lto = "thin"
- mlochbaum 4y agoUpdating my system, going to take a little while... Partner in crime dzaima has tested (nightly, unstable, lto) and found it is somewhat better. Eyeballing, still ~20% slower than fluxsort. We're on fairly old Intel x86-64 CPUs, i5-6200U for me and i3-4160 for him. Does panic safety really cost 10-15% when sorting integers according to default comparison?
- orlp 4y agoI get these results for your benchmark on my machine: https://gist.github.com/orlp/d7123ede0143e15ab0f8a435b7dd10b4 https://gist.github.com/orlp/d7123ede0143e15ab0f8a435b7dd10b... 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.
- mlochbaum 4y agoMakes sense regarding instruction-level parallelism; someone else with an M2 measured and found performance near identical to fluxsort. What did you take those results on? Collected graphs below. Orson: https://matrix.org/_matrix/media/r0/download/matrix.org/ldcdlOgPlomyQQkOZfJJYFTT https://matrix.org/_matrix/media/r0/download/matrix.org/ldcd... i3-4160: https://matrix.org/_matrix/media/r0/download/matrix.org/OBwSggTQOxzTRgiKqPuCuTCu https://matrix.org/_matrix/media/r0/download/matrix.org/OBwS... (edit) i5-6200U update: https://matrix.org/_matrix/media/r0/download/matrix.org/vzDrAiRipacENfnTHbfSUHpa https://matrix.org/_matrix/media/r0/download/matrix.org/vzDr... M2: https://matrix.org/_matrix/media/r0/download/matrix.org/ZRTjgFvqKwPsUiQkAaDbAxJi https://matrix.org/_matrix/media/r0/download/matrix.org/ZRTj...
- orlp 4y agoMy results are on a 2021 Apple M1 MacBook Pro. And I'd like to reiterate it's not 100% apples to apples comparing fluxsort and glidesort directly. One would need to either completely implement glidesort in unsafe C throwing Rust-isms as move-only types and panic safety out of the window, or implement fluxsort in Rust with the move-only restrictions and with the ability to restore all data in case of a panic. Only then could you truly compare the algorithms 100% fairly.
- nurettin 4y agoIn this particular case it sounds like Rust is just making things more tedious rather than providing value.
- kzrdude 4y agoThe end result is a generic sorting algorithm for Rust, which can be used for a lot of things /in Rust/, so it adds value to the Rust ecosystem. The sorting algorithm doesn't add anything without users :) so for non-academic implementations, maybe using it in Rust projects is what the author wants. Rust is also quite open to contributions, so it might be exciting if there's a chance to have it in Rust std.