Skip to content

Commit b81a6a5

Browse files
committed
adjust threshold
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
1 parent 01ddc15 commit b81a6a5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/pool/spawn.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ impl WorkersInfo for u64 {
8989
}
9090
}
9191

92-
const BACKUP_THRESHOLD: i64 = 64;
92+
const BACKUP_TO_ACTIVE_THRESHOLD: i64 = -16;
93+
const ACTIVE_TO_BACKUP_THRESHOLD: i64 = 128;
9394

9495
/// The core of queues.
9596
///
@@ -135,7 +136,7 @@ impl<T> QueueCore<T> {
135136
self.backup_count.store(0, Ordering::SeqCst);
136137
} else {
137138
backup_count = self.backup_count.fetch_sub(1, Ordering::SeqCst) - 1;
138-
while backup_count < -BACKUP_THRESHOLD {
139+
while backup_count < BACKUP_TO_ACTIVE_THRESHOLD {
139140
match self.backup_count.compare_exchange_weak(
140141
backup_count,
141142
0,
@@ -180,7 +181,7 @@ impl<T> QueueCore<T> {
180181
pub fn park_to_backup(&self) -> bool {
181182
let mut v = self.backup_count.load(Ordering::SeqCst);
182183
loop {
183-
if v < BACKUP_THRESHOLD {
184+
if v < ACTIVE_TO_BACKUP_THRESHOLD {
184185
return false;
185186
}
186187
match self

0 commit comments

Comments
 (0)