[llvm] Windows: use EcoQoS for ThreadPriority::Background (PR #148797)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 11:30:57 PDT 2025
================
@@ -107,6 +107,31 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
}
SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
+
+ typedef BOOL(WINAPI * SetThreadInformation_t)(
+ HANDLE hThread, THREAD_INFORMATION_CLASS ThreadInformationClass,
+ _In_reads_bytes_(ThreadInformationSize) PVOID ThreadInformation,
+ ULONG ThreadInformationSize);
+ static const auto pfnSetThreadInformation =
+ (SetThreadInformation_t)GetProcAddress(
+ GetModuleHandle(TEXT("kernel32.dll")), "SetThreadInformation");
+
+ if (pfnSetThreadInformation) {
+ if (Priority == ThreadPriority::Background) {
----------------
aganea wrote:
I think you should also cover the "else" case here, if the code decides to put back the thread in a higher priority state. In that case, we should revert the throttling by calling `SetThreadInformation` again with `.StateMask` set to zero.
https://github.com/llvm/llvm-project/pull/148797
More information about the llvm-commits
mailing list