@@ -50,21 +50,22 @@ lazy_static! {
50
50
} ;
51
51
}
52
52
53
- // Create up to 10,000 dynamic blocking task worker threads.
53
+ // Create up to MAX_THREADS dynamic blocking task worker threads.
54
54
// Dynamic threads will terminate themselves if they don't
55
55
// receive any work after a timeout that scales down as the
56
56
// total number of threads scales up.
57
57
fn maybe_create_another_blocking_thread ( ) {
58
+ // We use a `Relaxed` atomic operation because
59
+ // it's just a heuristic, and would not lose correctness
60
+ // even if it's random.
58
61
let workers = DYNAMIC_THREAD_COUNT . load ( Ordering :: Relaxed ) ;
59
62
if workers >= MAX_THREADS {
60
63
return ;
61
64
}
62
65
63
66
// We want to give up earlier when we have more threads
64
67
// to exert backpressure on the system submitting work
65
- // to do. We use a `Relaxed` atomic operation because
66
- // it's just a heuristic, and would not lose correctness
67
- // even if it's random.
68
+ // to do.
68
69
let utilization_percent = ( workers * 100 ) / MAX_THREADS ;
69
70
let relative_wait_limit = ( WAIT_SPREAD * utilization_percent) / 100 ;
70
71
@@ -93,6 +94,9 @@ fn maybe_create_another_blocking_thread() {
93
94
// timeout is dynamic, and when we have more threads we block
94
95
// for longer before spinning up another thread for backpressure.
95
96
fn schedule ( t : async_task:: Task < ( ) > ) {
97
+ // We use a `Relaxed` atomic operation because
98
+ // it's just a heuristic, and would not lose correctness
99
+ // even if it's random.
96
100
let workers = DYNAMIC_THREAD_COUNT . load ( Ordering :: Relaxed ) ;
97
101
98
102
// We want to block for longer when we have more threads to
0 commit comments