From 0283186046ac6e54470fbe2f74fa5135ddcad16b Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 1 Dec 2023 01:35:10 +0000 Subject: [PATCH] [*] Expand WakeOnAddress array and minor lookup optimization --- Source/Threading/AuWakeOnAddress.cpp | 8 +++++--- Source/Threading/AuWakeOnAddress.hpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Threading/AuWakeOnAddress.cpp b/Source/Threading/AuWakeOnAddress.cpp index 295a3254..f17a2de4 100644 --- a/Source/Threading/AuWakeOnAddress.cpp +++ b/Source/Threading/AuWakeOnAddress.cpp @@ -419,6 +419,8 @@ namespace Aurora::Threading this->uAtomic = 0; } + #define AddressToIndex AuHashCode(pAddressIDC) & (AuArraySize(this->list) - 1) + WaitEntry *ProcessWaitContainer::WaitBufferFrom(const void *pAddress, AuUInt8 uSize) { #if defined(FALLBACK_WAKEONADDRESS_SUPPORTS_NONEXACT_MATCHING) @@ -426,7 +428,7 @@ namespace Aurora::Threading #else auto pAddressIDC = pAddress; #endif - return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].WaitBufferFrom(pAddress, uSize); + return this->list[AddressToIndex].WaitBufferFrom(pAddress, uSize); } template @@ -437,7 +439,7 @@ namespace Aurora::Threading #else auto pAddressIDC = pAddress; #endif - return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].IterateWake(callback); + return this->list[AddressToIndex].IterateWake(callback); } void ProcessWaitContainer::RemoveSelf(const void *pAddress, WaitEntry *pSelf) @@ -447,7 +449,7 @@ namespace Aurora::Threading #else auto pAddressIDC = pAddress; #endif - return this->list[AuHashCode(pAddressIDC) % AuArraySize(this->list)].RemoveSelf(pSelf); + return this->list[AddressToIndex].RemoveSelf(pSelf); } bool IsNativeWaitOnSupported() diff --git a/Source/Threading/AuWakeOnAddress.hpp b/Source/Threading/AuWakeOnAddress.hpp index 82de4d64..17131e7b 100644 --- a/Source/Threading/AuWakeOnAddress.hpp +++ b/Source/Threading/AuWakeOnAddress.hpp @@ -12,7 +12,7 @@ namespace Aurora::Threading { - static const auto kDefaultWaitPerProcess = 64; + static const auto kDefaultWaitPerProcess = 128; struct WaitState;