tikv / yatp

Yet another thread pool in rust for both callbacks or futures.
Apache License 2.0
135 stars 32 forks source link

Reschedule only when there are awaiting tasks #30

Closed sticnarf closed 4 years ago

sticnarf commented 4 years ago

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.