From 66053e37f7334a266537cd24b4d5aa6ec4e2374d Mon Sep 17 00:00:00 2001 From: Terence Rokop Date: Sat, 5 Jun 2021 11:28:16 -0700 Subject: [PATCH] Add non-reentrant stats to SourceLocationZones Extend SourceLocationZones with fields to track the count and time of non-reentrant zone events -- that is, zone events which were the only appearances (at the time) of those zones on their threads' stacks. --- server/TracyWorker.cpp | 15 +++++++++++++++ server/TracyWorker.hpp | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index bdaf24d4..431a1e24 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -4798,6 +4798,13 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) if( slz->selfMin > selfSpan ) slz->selfMin = selfSpan; if( slz->selfMax < selfSpan ) slz->selfMax = selfSpan; slz->selfTotal += selfSpan; + if ( !isReentry ) + { + slz->nonReentrantCount++; + if( slz->nonReentrantMin > timeSpan ) slz->nonReentrantMin = timeSpan; + if( slz->nonReentrantMax < timeSpan ) slz->nonReentrantMax = timeSpan; + slz->nonReentrantTotal += timeSpan; + } if( !td->childTimeStack.empty() ) { td->childTimeStack.back() += timeSpan; @@ -7068,6 +7075,14 @@ void Worker::ReconstructZoneStatistics( SrcLocCountMap& countMap, ZoneEvent& zon if( slz.max < timeSpan ) slz.max = timeSpan; slz.total += timeSpan; slz.sumSq += double( timeSpan ) * timeSpan; + const auto isReentry = HasSrcLocCount( countMap, zone.SrcLoc() ); + if ( !isReentry ) + { + slz.nonReentrantCount++; + if( slz.nonReentrantMin > timeSpan ) slz.nonReentrantMin = timeSpan; + if( slz.nonReentrantMax < timeSpan ) slz.nonReentrantMax = timeSpan; + slz.nonReentrantTotal += timeSpan; + } if( zone.HasChildren() ) { auto& children = GetZoneChildren( zone.Child() ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index ec6b39c1..478ea5d8 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -184,6 +184,10 @@ private: int64_t selfMin = std::numeric_limits::max(); int64_t selfMax = std::numeric_limits::min(); int64_t selfTotal = 0; + size_t nonReentrantCount = 0; + int64_t nonReentrantMin = std::numeric_limits::max(); + int64_t nonReentrantMax = std::numeric_limits::min(); + int64_t nonReentrantTotal = 0; }; struct CallstackFrameIdHash