Skip to content

Commit 8c8104a

Browse files
committed
Add some more timers to Thread
1 parent 0375aeb commit 8c8104a

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/engine/renderer-vulkan/Thread/TaskList.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3939
#include "../Sys/CPUInfo.h"
4040
#include "../MiscCVarStore.h"
4141

42+
#include "ThreadMemory.h"
43+
4244
TaskList taskList;
4345

4446
TaskList::TaskList() {
@@ -293,11 +295,13 @@ Task* TaskList::FetchTask( Thread* thread, const bool longestTask ) {
293295
uint32_t task;
294296

295297
uint64_t mask = 0;
296-
while ( true ) {
297298

299+
TLM.fetchOuterTimer.Start();
300+
while ( true ) {
298301
uint64_t expected = mainTaskRing.queueLocks.load();
299302
uint64_t desired;
300303

304+
TLM.fetchQueueLockTimer.Start();
301305
while ( true ) {
302306
if ( expected == UINT64_MAX ) {
303307
std::this_thread::yield();
@@ -309,6 +313,9 @@ Task* TaskList::FetchTask( Thread* thread, const bool longestTask ) {
309313
queue = longestTask ? FindMZeroBit( queueLocks ) : FindLZeroBit( queueLocks );
310314

311315
if ( queue == 64 ) {
316+
317+
TLM.fetchQueueLockTimer.Stop();
318+
TLM.fetchOuterTimer.Stop();
312319
return nullptr;
313320
}
314321

@@ -320,6 +327,7 @@ Task* TaskList::FetchTask( Thread* thread, const bool longestTask ) {
320327

321328
break;
322329
}
330+
TLM.fetchQueueLockTimer.Stop();
323331

324332
task = FindLSB( mainTaskRing.queues[queue].availableTasks );
325333

@@ -343,6 +351,8 @@ Task* TaskList::FetchTask( Thread* thread, const bool longestTask ) {
343351

344352
mainTaskRing.UnlockQueue( queue );
345353

354+
TLM.fetchOuterTimer.Stop();
355+
346356
return tasks.memory + globalTaskID;
347357
}
348358

src/engine/renderer-vulkan/Thread/Thread.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ void Thread::Run() {
132132
exiting = taskList.ThreadFinished( true );
133133
}
134134

135+
fetchQueueLock = TLM.fetchQueueLockTimer.Time();
136+
fetchOuter = TLM.fetchOuterTimer.Time();
137+
135138
total.Stop();
136139
}
137140

@@ -146,4 +149,7 @@ void Thread::Exit() {
146149
Log::NoticeTag( "id: %u: total: %s, fetching: %s, execing: %s, idle: %s\n", id, total.FormatTime( Timer::ms ),
147150
fetching.FormatTime( Timer::ms ), execing.FormatTime( Timer::ms ),
148151
idle.FormatTime( Timer::ms ) );
152+
153+
Log::NoticeTag( "id: %u: fetch: queueLock: %s, outer: %s", id, Timer::FormatTime( fetchQueueLock, Timer::ms ),
154+
Timer::FormatTime( fetchOuter, Timer::ms ) );
149155
}

src/engine/renderer-vulkan/Thread/Thread.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class Thread :
7171
Timer fetching;
7272
Timer idle;
7373
Timer execing;
74+
75+
uint64_t fetchQueueLock;
76+
uint64_t fetchOuter;
7477
};
7578

7679
#endif // THREAD_H

src/engine/renderer-vulkan/Thread/ThreadMemory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class ThreadMemory {
8383
uint32_t id;
8484
ChunkAllocator chunkAllocators[MAX_MEMORY_AREAS];
8585

86+
GlobalTimer fetchOuterTimer;
87+
GlobalTimer fetchQueueLockTimer;
88+
8689
~ThreadMemory();
8790

8891
void Init();

0 commit comments

Comments
 (0)