-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Refactor scheduler and implement spinner thread for Partr. #56475
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
Open
gbaraldi
wants to merge
4
commits into
master
Choose a base branch
from
gb/sched-refact
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
vtjnash
reviewed
Nov 6, 2024
0d72173
to
9ecf779
Compare
Using function fib(n::Int)
n <= 1 && return n
t = Threads.@spawn fib(n - 2)
return fib(n - 1) + fetch(t)::Int
end as a benchmark this shows a pretty measurable improvement: julia> @benchmark fib(20)
BenchmarkTools.Trial: 1571 samples with 1 evaluation.
Range (min … max): 2.895 ms … 7.492 ms ┊ GC (min … max): 0.00% … 0.00%
Time (median): 2.958 ms ┊ GC (median): 0.00%
Time (mean ± σ): 3.181 ms ± 544.458 μs ┊ GC (mean ± σ): 6.30% ± 10.37%
▆█▃ ▁▁▁
███▇▄▄▁▁▁▁▁▃▅███████▇▆▅▅▅▅▅▇▅▆▅▅▅▇▆▆▄▅▆▅▃▅▆▃▆▅▄▅▅▄▅▃▄▃▃▁▄▁▄ █
2.9 ms Histogram: log(frequency) by time 5.45 ms <
Memory estimate: 3.71 MiB, allocs estimate: 67768 PR julia> @benchmark fib(20)
BenchmarkTools.Trial: 1882 samples with 1 evaluation.
Range (min … max): 2.403 ms … 5.918 ms ┊ GC (min … max): 0.00% … 57.77%
Time (median): 2.456 ms ┊ GC (median): 0.00%
Time (mean ± σ): 2.655 ms ± 501.850 μs ┊ GC (mean ± σ): 6.95% ± 11.26%
▆█▃ ▁▂▁
███▇▃▁▁▁▁▁▁▁▅▆█████▇▇▇▄▅▅▃▅▆▆▅▃▅▆▅▇▅▅▅▆▆▅▅▅▅▅▅▆▄▅▅▅▃▆▄▅▃▅▅▅ █
2.4 ms Histogram: log(frequency) by time 4.75 ms <
Memory estimate: 3.51 MiB, allocs estimate: 54732. While this benchmark isn't super comprehensive, it is pretty much just measuring scheduler latency, and given that this doesn't really change any scheduler decisions and just changes the wakeup logic it seems like a pretty nice improvement |
vchuravy
reviewed
Jan 24, 2025
vchuravy
reviewed
Jan 24, 2025
vchuravy
reviewed
Jan 24, 2025
vchuravy
reviewed
Jan 24, 2025
kpamnany
reviewed
Feb 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Also add option for child first
I'm splitting this from the workstealing PR to facilitate the reviews. This part should be much easier to merge.
The spinner design is rougly based on go's and mostly reuses the seq-cst barriers we have currently for sleeping. Though unlike n_threads_running the new counters rely on the thread being woken up so they will underreportThe new design doesnt care about how many threads are spinning, it just checks how many idle threads are available (we may want to combine this with threads running but they have slightly different ideas.
The performance gain is slight but does exist