Ability to resize the async main()'s thread pool from within #6420
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-runtime
Module: tokio/runtime
Is your feature request related to a problem? Please describe.
On AWS's
m7g.16xlarge
instances, the detected number of available CPU cores is sometimes 63 rather than 64, which is the actual number of VCPUs available. This slows down sufficiently parallel work.Describe the solution you'd like
A way for a
#[tokio::main] async fn main()
method to update the desired number of threads in the pool where it was running. The desired and actual numbers of threads would be stored in atomics with at leastOrdering::Acquire
for increases andOrdering::Release
for decreases (and I'm not 100% sure even that is enough; it's possibleOrdering::SeqCst
would be needed throughout). Whenever a thread was between tasks and the actual number of threads exceeded the desired number, that thread would terminate. Whenever the desired number of threads was less than the actual number, all the existing threads were busy, and a new task was submitted, that task would run right away on a new thread. (In other words, the actual number of threads would be able to exceed the desired number, but not for longer than m + n + O(1) where m and n were the top two task durations.)Describe alternatives you've considered
When I was using Rayon rather than Tokio, I could call the following from the sync
main()
:Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: