From 0f825b8cfdeab993a23f775555a4ec90a59dfab2 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 18:50:52 -0600 Subject: [PATCH] Use HIGH priority to wake blocked timers (cherry-pick #11269) (#11278) Cherry-picked Use HIGH priority to wake blocked timers (#11269) One contributor to some beach-balls was that the main thread was calling block_with_timeout, but the timeout never fired. Release Notes: - Reduced main thread hangs under very high system load Co-authored-by: Conrad Irwin --- crates/gpui/build.rs | 1 - crates/gpui/src/platform/mac/dispatcher.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index 1c87b391f693a3820f5c28642d2aebee30aa1bc7..060704291879b0c5dbcb7b3dd86554bb021b2e3b 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -38,7 +38,6 @@ mod macos { .header("src/platform/mac/dispatch.h") .allowlist_var("_dispatch_main_q") .allowlist_var("_dispatch_source_type_data_add") - .allowlist_var("DISPATCH_QUEUE_PRIORITY_DEFAULT") .allowlist_var("DISPATCH_QUEUE_PRIORITY_HIGH") .allowlist_var("DISPATCH_TIME_NOW") .allowlist_function("dispatch_get_global_queue") diff --git a/crates/gpui/src/platform/mac/dispatcher.rs b/crates/gpui/src/platform/mac/dispatcher.rs index 58375a7e48823679a3ca67f535c20a5d737f474d..d5ad010200164ae5e1ee349544f4dee8a0d29fd1 100644 --- a/crates/gpui/src/platform/mac/dispatcher.rs +++ b/crates/gpui/src/platform/mac/dispatcher.rs @@ -76,7 +76,7 @@ impl PlatformDispatcher for MacDispatcher { fn dispatch_after(&self, duration: Duration, runnable: Runnable) { unsafe { let queue = - dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.try_into().unwrap(), 0); + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH.try_into().unwrap(), 0); let when = dispatch_time(DISPATCH_TIME_NOW as u64, duration.as_nanos() as i64); dispatch_after_f( when,