From 386f714f5eb0681f7a7141b58944e662da8953e1 Mon Sep 17 00:00:00 2001 From: Evan Klitzke Date: Mon, 2 Dec 2019 19:20:39 -0800 Subject: [PATCH] Set indexer threads' priority to ThreadPriority::Background (#538) --- src/messages/initialize.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index b015d98d..9b9e2bb5 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -12,6 +12,7 @@ #include "working_files.hh" #include +#include #include #include @@ -255,6 +256,12 @@ void *indexer(void *arg_) { delete arg; std::string name = "indexer" + std::to_string(idx); set_thread_name(name.c_str()); + // Don't lower priority on __APPLE__. getpriority(2) says "When setting a + // thread into background state the scheduling priority is set to lowest + // value, disk and network IO are throttled." +#if LLVM_ENABLE_THREADS && LLVM_VERSION_MAJOR >= 9 && !defined(__APPLE__) + set_thread_priority(ThreadPriority::Background); +#endif pipeline::indexer_Main(h->manager, h->vfs, h->project, h->wfiles); pipeline::threadLeave(); return nullptr;