From dfe44317a04963b57b97053a69a65e51e9a5f1e1 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 9 Sep 2023 18:09:22 +0100 Subject: [PATCH] [*] SMT Yield: minor branch added to SMT Yield --- Source/Threading/Primitives/SMTYield.cpp | 2 ++ Source/Threading/Primitives/SMTYield.hpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Threading/Primitives/SMTYield.cpp b/Source/Threading/Primitives/SMTYield.cpp index 20e79575..79422850 100644 --- a/Source/Threading/Primitives/SMTYield.cpp +++ b/Source/Threading/Primitives/SMTYield.cpp @@ -81,6 +81,8 @@ namespace Aurora::Threading::Primitives gUseFutexRWLock = ThrdCfg::gPreferFutexRWLock && IsWaitOnRecommended(); + gSpinAdaptiveThreadCount = uCores; + if (uCores == 1) { gSpinAdaptiveThreshold = 0; diff --git a/Source/Threading/Primitives/SMTYield.hpp b/Source/Threading/Primitives/SMTYield.hpp index 412c3016..19b990b0 100644 --- a/Source/Threading/Primitives/SMTYield.hpp +++ b/Source/Threading/Primitives/SMTYield.hpp @@ -54,6 +54,7 @@ namespace Aurora::Threading::Primitives inline AuUInt32 gSpinAdaptiveThreshold {}; inline AuUInt32 gSpinAdaptiveCurrentCount {}; + inline AuUInt32 gSpinAdaptiveThreadCount {}; inline AuUInt32 gUseFutexRWLock {}; @@ -144,7 +145,7 @@ namespace Aurora::Threading::Primitives AuAtomicSub(&gSpinAdaptiveCurrentCount, 1u); } - else + else if (uNow <= gSpinAdaptiveThreadCount) { auto uCount = (spin) / 3; #if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86)