Use faster PRNG in the allocations profiler#57761
Merged
Conversation
`rand()` locks and is slow.
gbaraldi
approved these changes
Mar 13, 2025
vtjnash
approved these changes
Mar 13, 2025
kpamnany
added a commit
to RelationalAI/julia
that referenced
this pull request
Mar 13, 2025
`rand()` locks and is slow. This uses the seed from `ptls`.
3 tasks
kpamnany
added a commit
to RelationalAI/julia
that referenced
this pull request
Mar 27, 2025
* Use faster PRNG in the allocations profiler (JuliaLang#57761) `rand()` locks and is slow. This uses the seed from `ptls`. * Use correct arguments for 1.10's `cong()` Also remove a warning from array.c
Member
|
Before and after evidence of the improvement: 6 threads: julia> @time let out = zeros(Int, 1000)
Threads.@threads for i in 1:1000
out[i] += sum(Any[rand(Int) for i in 1:300000])
end
sum(out)
end
1.987923 seconds (600.03 M allocations: 11.178 GiB, 42.80% gc time, 4.52% compilation time)
-7843380098545669747
julia> using Profile
julia> @time Profile.Allocs.@profile sample_rate=0.000001 begin
let out = zeros(Int, 1000)
Threads.@threads for i in 1:1000
out[i] += sum(Any[rand(Int) for i in 1:300000])
end
sum(out)
end
end
8.568267 seconds (600.03 M allocations: 11.178 GiB, 9.67% gc time, 0.86% compilation time)
3995634343101539424shows a significant difference. After this PR, the difference is gone! 🎉 julia> @time let out = zeros(Int, 1000)
Threads.@threads for i in 1:1000
out[i] += sum(Any[rand(Int) for i in 1:300000])
end
sum(out)
end
1.934198 seconds (600.08 M allocations: 11.181 GiB, 43.48% gc time, 12.11% compilation time)
6985800949357430475
julia> using Profile
julia> @time Profile.Allocs.@profile sample_rate=0.000001 begin
let out = zeros(Int, 1000)
Threads.@threads for i in 1:1000
out[i] += sum(Any[rand(Int) for i in 1:300000])
end
sum(out)
end
end
2.157459 seconds (600.03 M allocations: 11.178 GiB, 39.03% gc time, 3.48% compilation time)
6035867019842016171 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rand()locks and is slow. This uses the seed fromptls.