Skip to content

Commit 12ebdd1

Browse files
committed
try to make threads better
1 parent a72e625 commit 12ebdd1

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/game/client/c_baseanimating.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2746,7 +2746,7 @@ ConVar cl_warn_thread_contested_bone_setup("cl_warn_thread_contested_bone_setup"
27462746
// Marked this developmentonly because it currently crashes, and users are enabling it and complaining because of
27472747
// course. Once this actually works it should just be FCVAR_INTERNAL_USE.
27482748
// UNDONE(mastercoms)
2749-
ConVar cl_threaded_bone_setup("cl_threaded_bone_setup", "0", FCVAR_INTERNAL_USE,
2749+
ConVar cl_threaded_bone_setup("cl_threaded_bone_setup", "1", FCVAR_INTERNAL_USE,
27502750
"Enable parallel processing of C_BaseAnimating::SetupBones()" );
27512751

27522752
//-----------------------------------------------------------------------------

src/tier0/threadtools.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,24 +1260,26 @@ int CStdThreadEvent::WaitForMultiple(int nEvents, CStdThreadEvent* const* pEvent
12601260
}
12611261
else if (timeout != 0) // We still haven't timed out, so let's wait
12621262
{
1263+
#if 0
12631264
// If we're already signaled, skip adding listeners
12641265
int tries = 0;
12651266
int backoff = 1;
12661267
constexpr int iSpinCount = 1000;
12671268
do {
1268-
if (CheckSignaledAll(nEvents, pEvents))
1269-
{
1270-
bRet = true;
1271-
break;
1272-
}
12731269
for (int yields = 0; yields < backoff; yields++) {
12741270
ThreadPause();
12751271
tries++;
12761272
}
12771273
constexpr int kMaxBackoff = 64;
12781274
backoff = min(kMaxBackoff, backoff << 1);
1275+
if (CheckSignaledAll(nEvents, pEvents))
1276+
{
1277+
bRet = true;
1278+
break;
1279+
}
12791280
} while (tries < iSpinCount);
12801281
if (!bRet)
1282+
#endif
12811283
{
12821284
switch (nEvents)
12831285
{
@@ -1397,24 +1399,26 @@ int CStdThreadEvent::WaitForMultiple(int nEvents, CStdThreadEvent* const* pEvent
13971399
}
13981400
else if (timeout != 0) // Do it one more time under a lock to make sure.
13991401
{
1402+
#if 0
14001403
// If we're already signaled, skip adding listeners
14011404
int tries = 0;
14021405
int backoff = 1;
14031406
constexpr int iSpinCount = 1000;
14041407
do {
1405-
if (CheckSignaledAny(nEvents, pEvents, iEventIndex))
1406-
{
1407-
bRet = true;
1408-
break;
1409-
}
14101408
for (int yields = 0; yields < backoff; yields++) {
14111409
ThreadPause();
14121410
tries++;
14131411
}
14141412
constexpr int kMaxBackoff = 64;
14151413
backoff = min(kMaxBackoff, backoff << 1);
1414+
if (CheckSignaledAny(nEvents, pEvents, iEventIndex))
1415+
{
1416+
bRet = true;
1417+
break;
1418+
}
14161419
} while (tries < iSpinCount);
14171420
if (!bRet)
1421+
#endif
14181422
{
14191423
// Lock all at the same time, to prevent race conditions.
14201424
// Before, this was implemented by locking and checking for each one after the other, which caused a race condition.

src/vstdlib/jobthread.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,11 @@ class CGlobalThreadPool : public CThreadPool
369369
{
370370
startParams.nThreads = nThreads;
371371
}
372-
startParams.iThreadPriority = TP_PRIORITY_LOW;
372+
else
373+
{
374+
startParams.nThreadsMax = 6;
375+
}
376+
startParams.iThreadPriority = TP_PRIORITY_HIGH;
373377
startParams.nStackSize = 128 * 1024;
374378
return CThreadPool::Start( startParams, "Glob" );
375379
}

0 commit comments

Comments
 (0)