When a future task requires to yield, it is expected that another task comes to running. However, if the pool is not busy or there isn't any other task to run, it is pure waste to put the task back to the global queue.
This PR tries to fix https://github.com/tikv/tikv/issues/6962. It is confirmed that with this PR the regression is solved.
However, the problem isn't actually resolved perfectly. If the pool is busy, the CPU cache of the yielded task will be flushed by other tasks. I don't have a good idea now. Maybe each working thread can have its own strategy of retrieving tasks.
When a future task requires to yield, it is expected that another task comes to running. However, if the pool is not busy or there isn't any other task to run, it is pure waste to put the task back to the global queue.
This PR tries to fix https://github.com/tikv/tikv/issues/6962. It is confirmed that with this PR the regression is solved. However, the problem isn't actually resolved perfectly. If the pool is busy, the CPU cache of the yielded task will be flushed by other tasks. I don't have a good idea now. Maybe each working thread can have its own strategy of retrieving tasks.