-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use an adaptive number of threads in the verification queue #2445
Conversation
an ideal solution would probably just balance the rate of queue draining vs the rate of verification per thread and adaptively allocate the correct number of threads based on that. this one uses some simple heuristics which seem to work decently well (although there's a bit more churn than I'd like) but it could be pretty simple to alter it to something more sophisticated. |
please add tests |
still no tests :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this heuristic might oscillate between, say, 4 and 5 threads
and each collect_garbage
call would be creating threads or wait for one thread to join
trace!(target: "verification", "v_rate_per={}, drained={}, scaling to {} verifiers", | ||
v_count_per, drained, needed); | ||
|
||
for _ in num_verifiers..needed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't extra 2 verifiers be added to the 7 verifiers
so that this check later will fail given ::num_cpus::get() == 8
?
if len == ::num_cpus::get() {
return;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, disregard this, they are added 1 by 1
still no need to call add_verifier
and lock self.verifiers
there once maximum is reached
@NikVolf I'll add tests once we figure out the right strategy for the adaptive threads. It's true that we don't want to be adding and removing threads all the time. Maybe a specialized thread pool where we allocate I also think the |
Ready for review again. Changes:
|
tests? |
tests :) @NikVolf could you approve the changes on your review now that I've addressed that grumble? |
No description provided.