-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pathological performance of .sort()
/ .sort_unstable()
#126945
Comments
I cannot reproduce with your example on Apple M2, with Can you please give exact reproduction instructions, as well as the platform on which you reproduced the problem? |
@lukaslueg do you mean rustup toolchain Note the difference:
EDIT: Can't reproduce with either. |
I am also skeptical of your claim that it ran in ~0.03s on 1.79-stable, that is an order of magnitude faster than on my machine, where it takes ~350ms. You have one mighty machine, if true. |
The problem turned out to be different profiles wrt to nightly. Sorry to have bothered. |
The following code executes in ~0.03s on 1.79-stable, and ~3.7s on nightly 2024-06-24; very roughly a 100x increase in runtime cost. Increasing the size of the slice increases the runtime cost to
3s
vs.~inf
, as you like.This showed up because some other code of mine started showing pathological behavior, which I traced back to the
sort_unstable()
; same behavior for.sort()
. My guess is that #124032 has something to do with it.The problem only shows up if
usize
is embedded in another type. In my code, it's aCell<Option<usize>>
(reasons!...), but the problem readily shows up with a simple newtype as well.I didn't investigate wether the quadratic-sawtooth-pattern reproduced below is actually part of the problem; its part of the data which originally caused me to investigate.
The text was updated successfully, but these errors were encountered: