Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit d778b9e

Browse files
committed
Set MAX_SIMILAR_CONCURRENT_WORK = 2
1 parent 255b766 commit d778b9e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/actions/work_pool.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ lazy_static! {
2020
/// Maximum total concurrent working tasks
2121
static ref NUM_THREADS: usize = ::num_cpus::get();
2222

23-
/// Maximum concurrent working tasks of the same type
24-
static ref MAX_SIMILAR_CONCURRENT_WORK: usize = (*NUM_THREADS / 2).max(1);
25-
2623
/// Duration of work after which we should warn something is taking a long time
2724
static ref WARN_TASK_DURATION: Duration = *DEFAULT_REQUEST_TIMEOUT * 5;
2825

@@ -37,6 +34,11 @@ lazy_static! {
3734
).unwrap();
3835
}
3936

37+
/// Maximum concurrent working tasks of the same type
38+
/// Note: `2` allows a single task to run immediately after a similar task has timed out.
39+
/// Once multiple tasks have timed out but remain running we start refusing to start new ones.
40+
const MAX_SIMILAR_CONCURRENT_WORK: usize = 2;
41+
4042
/// Runs work in a new thread on the `WORK_POOL` returning a result `Receiver`
4143
///
4244
/// Panicking work will receive `Err(RecvError)` / `Err(RecvTimeoutError::Disconnected)`
@@ -61,8 +63,7 @@ where
6163
);
6264
return receiver;
6365
}
64-
if work.iter().filter(|desc| *desc == &description).count() >= *MAX_SIMILAR_CONCURRENT_WORK
65-
{
66+
if work.iter().filter(|desc| *desc == &description).count() >= MAX_SIMILAR_CONCURRENT_WORK {
6667
// this type of work is already filling around half the work pool, so there's
6768
// good reason to believe it may fill the entire pool => fail fast to allow
6869
// other task-types to run

0 commit comments

Comments
 (0)