Skip to content

Commit

Permalink
Set indexer threads' priority to ThreadPriority::Background (MaskRay#538
Browse files Browse the repository at this point in the history
)
  • Loading branch information
eklitzke authored and MaskRay committed Dec 3, 2019
1 parent 2bc83ec commit e12131e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/messages/initialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "working_files.hh"

#include <llvm/ADT/Twine.h>
#include <llvm/Config/llvm-config.h>
#include <llvm/Support/Threading.h>

#include <rapidjson/document.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e12131e

Please sign in to comment.