Browse Source

Set indexer threads' priority to ThreadPriority::Background (#538)

pull/607/head
Evan Klitzke 5 years ago
committed by Fangrui Song
parent
commit
386f714f5e
  1. 7
      src/messages/initialize.cc

7
src/messages/initialize.cc

@ -12,6 +12,7 @@
#include "working_files.hh" #include "working_files.hh"
#include <llvm/ADT/Twine.h> #include <llvm/ADT/Twine.h>
#include <llvm/Config/llvm-config.h>
#include <llvm/Support/Threading.h> #include <llvm/Support/Threading.h>
#include <rapidjson/document.h> #include <rapidjson/document.h>
@ -255,6 +256,12 @@ void *indexer(void *arg_) {
delete arg; delete arg;
std::string name = "indexer" + std::to_string(idx); std::string name = "indexer" + std::to_string(idx);
set_thread_name(name.c_str()); 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::indexer_Main(h->manager, h->vfs, h->project, h->wfiles);
pipeline::threadLeave(); pipeline::threadLeave();
return nullptr; return nullptr;

Loading…
Cancel
Save