This repository was archived by the owner on Dec 29, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,6 @@ lazy_static! {
20
20
/// Maximum total concurrent working tasks
21
21
static ref NUM_THREADS : usize = :: num_cpus:: get( ) ;
22
22
23
- /// Maximum concurrent working tasks of the same type
24
- static ref MAX_SIMILAR_CONCURRENT_WORK : usize = ( * NUM_THREADS / 2 ) . max( 1 ) ;
25
-
26
23
/// Duration of work after which we should warn something is taking a long time
27
24
static ref WARN_TASK_DURATION : Duration = * DEFAULT_REQUEST_TIMEOUT * 5 ;
28
25
@@ -37,6 +34,11 @@ lazy_static! {
37
34
) . unwrap( ) ;
38
35
}
39
36
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
+
40
42
/// Runs work in a new thread on the `WORK_POOL` returning a result `Receiver`
41
43
///
42
44
/// Panicking work will receive `Err(RecvError)` / `Err(RecvTimeoutError::Disconnected)`
61
63
) ;
62
64
return receiver;
63
65
}
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 {
66
67
// this type of work is already filling around half the work pool, so there's
67
68
// good reason to believe it may fill the entire pool => fail fast to allow
68
69
// other task-types to run
You can’t perform that action at this time.
0 commit comments