From 209d1939aa9002d87501c3f44b25563529c3ce7f Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sun, 27 Aug 2023 21:27:49 +0100 Subject: [PATCH] [*] Tweak default thread config --- Include/Aurora/Runtime.hpp | 8 ++++---- Source/Async/ThreadPool.cpp | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Include/Aurora/Runtime.hpp b/Include/Aurora/Runtime.hpp index 4614d6c1..ddd85dce 100644 --- a/Include/Aurora/Runtime.hpp +++ b/Include/Aurora/Runtime.hpp @@ -346,7 +346,7 @@ namespace Aurora bool bNoThreadNames { false }; bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar before yielding into the kernel - AuUInt8 uSpinLoopPowerA { 40 }; // Nudgable spinloop power. This is our local userland niceness factor + AuUInt8 uSpinLoopPowerA { 80 }; // Nudgable spinloop power. This is our local userland niceness factor // This is comparable to Win32's SetCriticalSectionSpinCount applied across every single AuThreadPrimitives try-lock and lock. // Adjust this value to compensate for longer critical sections when context switching isn't preferrable. AuUInt8 uSpinLoopLinearBit { 1 }; @@ -366,15 +366,15 @@ namespace Aurora AuUInt64 bPreferWaitOnAddressAlwaysSpin : 1 { true }; // ..., if emulated! if double-spinning under higher level locks, disable me. AuUInt64 bPreferRWLockReadLockSpin : 1 { true }; AuUInt64 bUWPNanosecondEmulationCheckFirst : 1 { false }; - AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 }; AuUInt64 bForceEnableAdaptiveSpin : 1 { false }; AuUInt64 bPreferEnableAdaptiveSpin : 1 { true }; + AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 }; AuUInt64 bPreferLinuxAdaptiveSpin : 1 { true }; - AuUInt64 bPreferOldWin32AdaptiveSpin : 1 { true }; + AuUInt64 bPreferOldWin32AdaptiveSpin : 1 { false }; AuUInt64 bPreferNewWin32AdaptiveSpin : 1 { true }; AuUInt64 uAdaptiveSpinCUCnt0 : 4 { 0 }; AuUInt64 uAdaptiveSpinCUCnt4 : 4 { 2 }; - AuUInt64 uAdaptiveSpinCUCnt8 : 4 { 3 }; + AuUInt64 uAdaptiveSpinCUCnt8 : 4 { 2 }; AuUInt64 uAdaptiveSpinCUCnt16 : 4 { 4 }; AuUInt64 bPreferFutexRWLock : 1 { true }; AuUInt64 bWinXpThrough7BlazeOptimizerPower : 7 { 6 }; // dont worry about it. we dont care about old portables. lets try to make older win32 targets tweak the scheduling in our favor a bit. diff --git a/Source/Async/ThreadPool.cpp b/Source/Async/ThreadPool.cpp index d2d52ca5..dbe6ab9c 100644 --- a/Source/Async/ThreadPool.cpp +++ b/Source/Async/ThreadPool.cpp @@ -151,7 +151,9 @@ namespace Aurora::Async } else { - AU_LOCK_GUARD(pWorker->cvWorkMutex); + { + AU_LOCK_GUARD(pWorker->cvWorkMutex); + } pWorker->cvVariable->Signal(); pWorker->eventLs->Set();