mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
Tune drop_excess_capacity
This commit is contained in:
@@ -152,14 +152,14 @@ pub(super) fn job_already_done(&mut self) {
|
||||
|
||||
fn drop_excess_capacity(&mut self) {
|
||||
self.assert_invariants();
|
||||
if self.active_jobs == self.pending_jobs {
|
||||
// Drop all excess tokens
|
||||
self.tokens.truncate(std::cmp::max(self.active_jobs, 1));
|
||||
} else {
|
||||
// Keep some excess tokens to satisfy requests faster
|
||||
const MAX_EXTRA_CAPACITY: usize = 2;
|
||||
self.tokens.truncate(std::cmp::max(self.active_jobs + MAX_EXTRA_CAPACITY, 1));
|
||||
}
|
||||
|
||||
// Drop all tokens that can never be used anymore
|
||||
self.tokens.truncate(std::cmp::max(self.pending_jobs, 1));
|
||||
|
||||
// Keep some excess tokens to satisfy requests faster
|
||||
const MAX_EXTRA_CAPACITY: usize = 2;
|
||||
self.tokens.truncate(std::cmp::max(self.active_jobs + MAX_EXTRA_CAPACITY, 1));
|
||||
|
||||
self.assert_invariants();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user