-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateC-enhancementCategory: A PR with an enhancement or bugfix.Category: A PR with an enhancement or bugfix.M-blockingModule: tokio/task/blockingModule: tokio/task/blockingT-performanceTopic: performance and benchmarksTopic: performance and benchmarks
Description
Code that invokes spawn_blocking, or block_in_place (which internally calls spawn_blocking), all end up taking a shared lock here:
tokio/tokio/src/runtime/blocking/pool.rs
Line 153 in 221f421
| let mut shared = self.inner.shared.lock().unwrap(); |
This causes a lot of unnecessary contention between unrelated tasks if you frequently need to run blocking code. The problem is exacerbated as load increases, because more calls to spawn_blocking causes each individual call to become more expensive, and each call holds up an executor thread.
bryanhitc, privettoli, pickfire and estaban
Metadata
Metadata
Assignees
Labels
A-tokioArea: The main tokio crateArea: The main tokio crateC-enhancementCategory: A PR with an enhancement or bugfix.Category: A PR with an enhancement or bugfix.M-blockingModule: tokio/task/blockingModule: tokio/task/blockingT-performanceTopic: performance and benchmarksTopic: performance and benchmarks