diff --git a/src/nvim/main.c b/src/nvim/main.c index 387523c571..5c1e415cb7 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -190,6 +190,7 @@ static bool event_teardown(void) /// Needed for unit tests. void early_init(mparm_T *paramp) { + os_hint_priority(); estack_init(); cmdline_init(); eval_init(); // init global variables diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 21da64a1ee..940d2236a7 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -39,6 +39,10 @@ # include "nvim/fileio.h" #endif +#ifdef __APPLE__ +# include +#endif + #ifdef HAVE__NSGETENVIRON # include #endif @@ -352,6 +356,18 @@ int64_t os_get_pid(void) #endif } +/// Signals to the OS that Nvim is an application for "interactive work" +/// which should be prioritized similar to a GUI app. +void os_hint_priority(void) +{ +#ifdef __APPLE__ + // By default, processes have the TASK_UNSPECIFIED "role", which means all of its threads are + // clamped to Default QoS. Setting the role to TASK_DEFAULT_APPLICATION removes this clamp. + integer_t policy = TASK_DEFAULT_APPLICATION; + task_policy_set(mach_task_self(), TASK_CATEGORY_POLICY, &policy, 1); +#endif +} + /// Gets the hostname of the current machine. /// /// @param hostname Buffer to store the hostname.