Skip to content

Commit 502dce1

Browse files
committed
Sync taskTimes only every 64-th execution
1 parent 684fa2a commit 502dce1

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/engine/Base/Thread/Thread.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,25 @@ void Thread::Run() {
152152
taskTime.count++;
153153
taskTime.time += taskExecTime;
154154

155-
if ( !taskTime.syncedWithSM ) {
156-
while( !SM.taskTimesLock.LockWrite() );
155+
if ( !( taskTime.count & 63 ) ) {
156+
if ( !taskTime.syncedWithSM ) {
157+
while ( !SM.taskTimesLock.LockWrite() );
157158

158-
GlobalTaskTime& SMTaskTime = SM.taskTimes[task->Execute];
159-
SMTaskTime.count = 1;
160-
SMTaskTime.time = taskExecTime;
161-
taskTime.syncedWithSM = true;
159+
GlobalTaskTime& SMTaskTime = SM.taskTimes[task->Execute];
160+
SMTaskTime.count = 1;
161+
SMTaskTime.time = taskExecTime;
162+
taskTime.syncedWithSM = true;
162163

163-
SM.taskTimesLock.UnlockWrite();
164-
} else {
165-
while( !SM.taskTimesLock.Lock() );
164+
SM.taskTimesLock.UnlockWrite();
165+
} else {
166+
while ( !SM.taskTimesLock.Lock() );
166167

167-
GlobalTaskTime& SMTaskTime = SM.taskTimes[task->Execute];
168-
SMTaskTime.count.fetch_add( 1, std::memory_order_relaxed );
169-
SMTaskTime.time.fetch_add( taskExecTime, std::memory_order_relaxed );
168+
GlobalTaskTime& SMTaskTime = SM.taskTimes[task->Execute];
169+
SMTaskTime.count.fetch_add( 1, std::memory_order_relaxed );
170+
SMTaskTime.time.fetch_add( taskExecTime, std::memory_order_relaxed );
170171

171-
SM.taskTimesLock.Unlock();
172+
SM.taskTimesLock.Unlock();
173+
}
172174
}
173175

174176
task = nullptr;

0 commit comments

Comments
 (0)