[*] Tweak default thread config

[*] Fix regressions
This commit is contained in:
Reece Wilson 2023-08-27 21:27:49 +01:00
parent b2e1df8f72
commit 55c02d4aa0
3 changed files with 41 additions and 30 deletions

View File

@ -344,12 +344,11 @@ namespace Aurora
{
// WARN: these values are not final
bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar before yielding into the kernel
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 };
bool bNoThreadNames { false };
bool bPlatformIsSMPProcessorOptimized { true }; // Whether to attempt to using mm_pause or similar instruction before yielding into the kernel
AuUInt16 uSpinLoopPowerA { 128 }; // 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.
AuUInt64 bEnableAggressiveScheduling : 1 { false };
AuUInt64 bEnableAgrSchedulingRatelimit : 1 { true };
AuUInt64 bPreferNt51XpMutexesOver8 : 1 { false };
@ -366,10 +365,10 @@ 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 bForceEnableAdaptiveSpin : 1 { false };
AuUInt64 bPreferEnableAdaptiveSpin : 1 { true };
AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 };
AuUInt64 bPreferLinuxAdaptiveSpin : 1 { true };
AuUInt64 uUWPNanosecondEmulationMaxYields : 7 { 12 };
AuUInt64 bForceEnableAdaptiveSpin : 1 { false }; // ||
AuUInt64 bPreferEnableAdaptiveSpin : 1 { true }; // &&
AuUInt64 bPreferLinuxAdaptiveSpin : 1 { true }; // &&
AuUInt64 bPreferOldWin32AdaptiveSpin : 1 { false };
AuUInt64 bPreferNewWin32AdaptiveSpin : 1 { true };
AuUInt64 uAdaptiveSpinCUCnt0 : 4 { 0 };

View File

@ -485,7 +485,6 @@ namespace Aurora::Async
{
if (InRunnerMode())
{
if ((this->uAtomicCounter == 0) &&
this->IsDepleted())
{

View File

@ -56,31 +56,36 @@ namespace Aurora::Threading::Primitives
int loops = spin;
while (loops > 0)
{
loops -= 1;
if (callback())
{
AuAtomicSub(&gSpinAdaptiveCurrentCount, 1u);
return true;
}
else
{
SMPPause();
SMPPause();
SMPPause();
SMPPause();
loops -= 4;
}
}
if (gHasThreadLocalTimeout)
{
auto uCount = tlsSpinCountLocal;
int loops = (1 << uCount);
int loops = (1 << tlsSpinCountLocal);
while (loops > 0)
{
SMPPause();
loops -= 1;
if (callback())
{
AuAtomicSub(&gSpinAdaptiveCurrentCount, 1u);
return true;
}
else
{
SMPPause();
loops--;
}
}
}
@ -91,15 +96,16 @@ namespace Aurora::Threading::Primitives
int loops = (spin) / 3;
while (loops > 0)
{
SMPPause();
loops -= 1;
if (callback())
{
AuAtomicSub(&gSpinAdaptiveCurrentCount, 1u);
return true;
}
else
{
SMPPause();
loops --;
}
}
}
@ -110,12 +116,18 @@ namespace Aurora::Threading::Primitives
int loops = spin;
while (loops > 0)
{
loops -= 1;
if (callback())
{
return true;
}
else
{
SMPPause();
SMPPause();
SMPPause();
SMPPause();
loops -= 4;
}
}
if (gHasThreadLocalTimeout)
@ -125,14 +137,15 @@ namespace Aurora::Threading::Primitives
int loops = (1 << uCount);
while (loops > 0)
{
SMPPause();
loops -= 1;
if (callback())
{
return true;
}
else
{
SMPPause();
loops --;
}
}
}
}