reduce default executor spins from 4 to 0#262
Merged
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
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.
Previously the work stealing loop would only pause between each full round of work stealing attempts. Now, there is a pause inside of the work stealing loop to reduce cross-cache traffic. As a result, the overall work stealing operation takes a bit longer to complete. That change went out in v1.6. BTW, I profiled it across all workloads and didn't observe any negative effects - it seemed to only help.
I have, however, noticed that extra spinning doesn't seem to be helpful under this new regime. It pollutes lightly-loaded / latency-bound profiles with a lot of
ex_cpu::make_workertime that isn't doing anything. For cases where you want to actively spin to minimize latency, you'll want toset_spins()to a much higher than the old default of 4 - probably to something like 100+. So I'm changing the default spins to 0.There's still 1 guaranteed spin baked into the design - after failing to find work and marking the thread as going to sleep, we have to double check all the queues. Then, there is a
std::atomic::wait()on the sleep_wait variable, which does some spinning internally.