Open
Description
I suspect that changes in Julia's random number generation has caused micro-optimisations in the implementation of shuffle!
to harm rather than help performance.
julia/stdlib/Random/src/misc.jl
Lines 208 to 221 in 4db8c1b
On my machine, I observe a naive Fisher-Yates shuffle outperforms an array of 10,000 floats by a factor of ~2 (x86_64 Linux, with Julia 1.11.4)
julia> function myshuf!(vec)
for i in eachindex(vec)
j = rand(i:length(vec))
vec[i], vec[j] = vec[j], vec[i]
end
vec
end
myshuf! (generic function with 1 method)
julia> vec = rand(10000);
julia> @b shuffle!(vec)
40.325 μs
julia> @b myshuf!(vec)
20.085 μs