Skip to content

Commit 16b39f8

Browse files
committed
Log some Task timing information
1 parent a11c7c6 commit 16b39f8

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ void Thread::Run() {
7070

7171
total.Start();
7272

73-
struct TaskTime {
74-
uint64_t count = 0;
75-
uint64_t time = 0;
76-
};
77-
78-
std::unordered_map<Task::TaskFunction, TaskTime> taskTimes;
79-
8073
while ( !exiting ) {
8174
if ( !running ) {
8275
std::this_thread::yield();
@@ -124,8 +117,8 @@ void Thread::Run() {
124117

125118
t.Stop();
126119

127-
taskTimes[task->Execute].count++;
128-
taskTimes[task->Execute].time += t.Time();
120+
TLM.taskTimes[task->Execute].count++;
121+
TLM.taskTimes[task->Execute].time += t.Time();
129122

130123
task = nullptr;
131124

@@ -140,6 +133,8 @@ void Thread::Run() {
140133
taskAdd = TLM.addTimer.Time();
141134
taskSync = TLM.syncTimer.Time();
142135

136+
taskTimes = TLM.taskTimes;
137+
143138
total.Stop();
144139
}
145140

@@ -158,4 +153,10 @@ void Thread::Exit() {
158153
Log::NoticeTag( "id: %u: fetch: queueLock: %s, outer: %s, add: %s, sync: %s", id,
159154
Timer::FormatTime( fetchQueueLock, Timer::ms ), Timer::FormatTime( fetchOuter, Timer::ms ),
160155
Timer::FormatTime( taskAdd, Timer::ms ), Timer::FormatTime( taskSync, Timer::ms ) );
156+
157+
for ( const std::pair<Task::TaskFunction, TaskTime>& taskTime : taskTimes ) {
158+
Log::NoticeTag( "task: avg: %s, count: %u, time: %u",
159+
Timer::FormatTime( taskTime.second.time / taskTime.second.count, Timer::us ),
160+
taskTime.second.count, taskTime.second.time );
161+
}
161162
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4444
#include "../Shared/Timer.h"
4545
#include "../SrcDebug/Tag.h"
4646

47+
struct TaskTime;
48+
4749
class Thread :
4850
public Tag {
4951
public:
@@ -78,6 +80,8 @@ class Thread :
7880

7981
uint64_t taskAdd;
8082
uint64_t taskSync;
83+
84+
std::unordered_map<Task::TaskFunction, TaskTime> taskTimes;
8185
};
8286

8387
#endif // THREAD_H

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4141

4242
#include "../Memory/DynamicArray.h"
4343
#include "../Memory/MemoryChunk.h"
44+
#include "Task.h"
4445

4546
using byte = uint8_t;
4647

@@ -78,6 +79,11 @@ struct ChunkAllocator {
7879
DynamicArray<MemoryChunkRecord> chunks;
7980
};
8081

82+
struct TaskTime {
83+
uint64_t count = 0;
84+
uint64_t time = 0;
85+
};
86+
8187
class ThreadMemory {
8288
public:
8389
static constexpr uint32_t MAIN_ID = UINT32_MAX;
@@ -87,6 +93,8 @@ class ThreadMemory {
8793

8894
ChunkAllocator chunkAllocators[MAX_MEMORY_AREAS];
8995

96+
std::unordered_map<Task::TaskFunction, TaskTime> taskTimes;
97+
9098
GlobalTimer fetchOuterTimer;
9199
GlobalTimer fetchQueueLockTimer;
92100

0 commit comments

Comments
 (0)