You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
faster rand(TaskLocalRNG(), 1:n) by outlining throw
In #58089, this method took a small performance hit in some contexts.
It turns out that by outlining unlikely branch which throw on empty
ranges, his hit can be recovered.
In #50509 (comment),
a graph of the performance improvement of the "speed-up randperm by using
our current rand(1:n)" was posted, but I realized it was only true when
calls to `rand(1:n)` were prefixed by `@inline`; without `@inline` it was
overall slower for `TaskLocalRNG()` for very big arrays (but still faster
otherwise).
An alternative to these `@inline` annotation is to outline `throw` like here,
for equivalent benefits as `@inline` in that `randperm` PR.
Assuming that PR is merged, this PR improves roughly performance by 2x for
`TaskLocalRNG()` (no change for other RNGs).
0 commit comments