-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateE-hardCall for participation: Experience needed to fix: Hard / a lotCall for participation: Experience needed to fix: Hard / a lotE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.M-runtimeModule: tokio/runtimeModule: tokio/runtimeM-timeModule: tokio/timeModule: tokio/timeT-performanceTopic: performance and benchmarksTopic: performance and benchmarks
Description
I have often heard reports about performance issues due to large amounts of timers. Specifically, this is due to contention on the mutex in the timer driver.
Some ideas:
- If a
Sleep
instance is dropped before it is polled, its destructor will still lock the mutex to check whether it needs to be removed from the driver. This seems unnecessary, and will be a common case for timeouts. - We could shard the timer into multiple instances with one per runtime thread.
- It's worth thinking about whether our timers are optimized for the case where most timers complete normally (often the case of
tokio::time::sleep
), or the case where most timers are cancelled before they complete (often the case for timeouts). Can we do anything to differentiate this in the driver? - Perhaps a completely different implementation is appropriate?
Before spending a lot of time on a large change, please check with us beforehand by posting here or in Discord so that we can discuss whether your implementation idea is what we want.
PRs related to this issue:
FrankReh, trungda, lyang24, kushudai and Congyuwang
Metadata
Metadata
Assignees
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateE-hardCall for participation: Experience needed to fix: Hard / a lotCall for participation: Experience needed to fix: Hard / a lotE-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.M-runtimeModule: tokio/runtimeModule: tokio/runtimeM-timeModule: tokio/timeModule: tokio/timeT-performanceTopic: performance and benchmarksTopic: performance and benchmarks