Skip to content

Commit ab613a5

Browse files
author
Tyler Neely
committed
Improve comments in the blocking threadpool
1 parent 4cb1faf commit ab613a5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/task/blocking.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,22 @@ lazy_static! {
5050
};
5151
}
5252

53-
// Create up to 10,000 dynamic blocking task worker threads.
53+
// Create up to MAX_THREADS dynamic blocking task worker threads.
5454
// Dynamic threads will terminate themselves if they don't
5555
// receive any work after a timeout that scales down as the
5656
// total number of threads scales up.
5757
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.
5861
let workers = DYNAMIC_THREAD_COUNT.load(Ordering::Relaxed);
5962
if workers >= MAX_THREADS {
6063
return;
6164
}
6265

6366
// We want to give up earlier when we have more threads
6467
// 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.
6869
let utilization_percent = (workers * 100) / MAX_THREADS;
6970
let relative_wait_limit = (WAIT_SPREAD * utilization_percent) / 100;
7071

@@ -93,6 +94,9 @@ fn maybe_create_another_blocking_thread() {
9394
// timeout is dynamic, and when we have more threads we block
9495
// for longer before spinning up another thread for backpressure.
9596
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.
96100
let workers = DYNAMIC_THREAD_COUNT.load(Ordering::Relaxed);
97101

98102
// We want to block for longer when we have more threads to

0 commit comments

Comments
 (0)