Make block_with_timeout more robust (#11670)
The previous implementation relied on a background thread to wake up the main thread, which was prone to priority inversion under heavy load. In a synthetic test, where we spawn 200 git processes while doing a 5ms timeout, the old version blocked for 5-80ms, the new version blocks for 5.1-5.4ms. Release Notes: - Improved responsiveness of the main thread under high system load
This commit is contained in:
parent
b34ab6f3a1
commit
c73d6502d6
6 changed files with 160 additions and 135 deletions
|
@ -87,12 +87,13 @@ impl PlatformDispatcher for MacDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
fn tick(&self, _background_only: bool) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn park(&self) {
|
||||
self.parker.lock().park()
|
||||
fn park(&self, timeout: Option<Duration>) -> bool {
|
||||
if let Some(timeout) = timeout {
|
||||
self.parker.lock().park_timeout(timeout)
|
||||
} else {
|
||||
self.parker.lock().park();
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fn unparker(&self) -> Unparker {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue