[PATCH] D124715: Use QoS class Utility for ThreadPriority::Low on Mac

Stefan Haller via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 30 07:55:04 PDT 2022


stefanhaller created this revision.
Herald added subscribers: dexonsmith, usaxena95, kadircet, arphaman, hiraditya.
Herald added a project: All.
stefanhaller requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, ilya-biryukov.
Herald added projects: clang, LLVM, clang-tools-extra.

On Apple Silicon Macs, using a Darwin thread priority of PRIO_DARWIN_BG seems to
map directly to the QoS class Background. With this priority, the thread is
confined to efficiency cores only, which makes background indexing take forever.

Change this to use QoS class Utility instead; this makes the thread run on all
cores, but still lowers priority enough to keep the machine responsive, and not
interfere with user-initiated actions.

Also, rename ThreadPriority::Background to ThreadPriority::Low; this avoids
confusion with the QoS class Background, and allows to reintroduce
ThreadPriority::Background later, should there be a need for it.

We might consider changing the Windows and Linux implementations too (e.g. using
SCHED_BATCH instead of SCHED_IDLE on Linux). I didn't do that here because I
don't have access to these systems to test it on.

See also https://github.com/clangd/clangd/issues/1119.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124715

Files:
  clang-tools-extra/clangd/index/Background.h
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Support/Threading.h
  llvm/lib/Support/Unix/Threading.inc
  llvm/lib/Support/Windows/Threading.inc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124715.426231.patch
Type: text/x-patch
Size: 4847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220430/39904248/attachment.bin>


More information about the llvm-commits mailing list