From 197007ab479d08087e8b4803f7eb21b4f5cf0f7b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 18 Aug 2022 13:59:56 +0200 Subject: [PATCH] Keep a list of buffers left to handle. Previously a bitmap of buffers was repeatedly scanned to see which buffers still contain data. This process was needlessly wasting cycles (seen as a hotspot when profiled) and worse yet, the workload increased with the number of CPU cores (=> buffers used) to handle. The new implementation instead maintains a list of buffer indices that have to be handled. This list does not contain empty buffers, so each loop iteration performs some work, instead of just spinning in search for buffers to handle. --- public/client/TracySysTrace.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/public/client/TracySysTrace.cpp b/public/client/TracySysTrace.cpp index 87fe2086..ee62547d 100644 --- a/public/client/TracySysTrace.cpp +++ b/public/client/TracySysTrace.cpp @@ -1285,7 +1285,7 @@ void SysTraceWorker( void* ptr ) const auto ctxBufNum = numBuffers - ctxBufferIdx; int activeNum = 0; - bool active[512]; + uint16_t active[512]; uint32_t end[512]; uint32_t pos[512]; for( int i=0; i 0 ) { int sel = -1; + int selPos; int64_t t0 = std::numeric_limits::max(); - for( int i=0; i