Use unstable instead of stable sorts#358
Conversation
Unstable sorting has significantly better code size (and often better performance too). With this change (rebased on top of v0.25.0, which is what std currently uses) the .text size of Rust hello world (with `-Clto=fat -Copt-level=s`) goes from 297120 to 290351 (-2.23%). I do not know *that* much about addr2line, so I cannot guarantee that this code is fine with unstable sorting. But I think it should be fine since it always sorts on addresses, which are either unique or nondeterministic anyways (as mentioned in one comment even). So it should not make a significant difference.
|
For correctness, I agree that this should only affect parts that were nondeterministic anyway. However, running The performance difference when running
|
Not necessary for correctness, but helps compare results.
|
I ran the benchmarks locally and also saw a few small performance slowdowns, but I'm not sure whether it's really significant. Stable vs unstable sorting performance varies a bunch, where either can be faster depending on the circumstances. |
|
Does rust have an equivalent of C's |
The |


Unstable sorting has significantly better code size (and often better performance too). With this change (rebased on top of v0.25.0, which is what std currently uses) the .text size of Rust hello world (with
-Clto=fat -Copt-level=s) goes from 297120 to 290351 (-2.23%).I do not know that much about addr2line, so I cannot guarantee that this code is fine with unstable sorting. But I think it should be fine since it always sorts on addresses, which are either unique or nondeterministic anyways (as mentioned in one comment even). So it should not make a significant difference.