steal other workers only before going to sleep#32
steal other workers only before going to sleep#32sticnarf wants to merge 4 commits intotikv:masterfrom
Conversation
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
|
How does it performs? |
|
Cool, what does criterion say? |
Criterion shows 5% to 20% regression while CPU time is reduced more than 50%. I have no idea what the regression comes from. I don't see imbalance among threads through |
|
I find the criterion microbenchmark is strongly associated with Although that's not the real case, I doubt if we really should yield. It is noticed many time that |
|
Not yield will lead to frequently sleep and awake. You should not just check spawn_many, but also other bench results. |
All microbenchmarks show improvements except Yes, not yielding can lead to more frequent sleep and wake. But it's not that clear to me how it compares to some random scheduling among the OS. |
|
Very strange that I run benchmark on your code only ping_pong instead of spawn_many shows a significant regression, about 300%. |
Signed-off-by: Yilin Chen <sticnarf@gmail.com>

This PR is to mitigate the regression reported in tikv/tikv#7122 by changing the strategy of
pop.It is found that CPU is mostly wasted in stealing other workers. The situation is especially terrible when there are lots of threads.
It makes little sense to steal other workers every time we call
pop. We only need to make sure that the working threads never go to sleep while leaving other workers too busy. So we actually only need to steal other workers before going to sleep.