From 710a488af0b811426faf62e59f382cbadda62ef9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 14 Nov 2021 23:48:50 +0100 Subject: [PATCH] Handle postponed samples with SortedVector. --- server/TracyEvent.hpp | 4 +++- server/TracyWorker.cpp | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 4bdbecfb..8e00a90a 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -264,6 +264,8 @@ struct SampleData enum { SampleDataSize = sizeof( SampleData ) }; +struct SampleDataSort { bool operator()( const SampleData& lhs, const SampleData& rhs ) { return lhs.time.Val() < rhs.time.Val(); }; }; + struct SampleDataRange { @@ -633,7 +635,7 @@ struct ThreadData Vector childTimeStack; Vector ghostZones; uint64_t ghostIdx; - Vector postponedSamples; + SortedVector postponedSamples; #endif Vector samples; SampleData pendingSample; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 51c52c1f..b0e36159 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -4358,11 +4358,7 @@ void Worker::DoPostponedWork() auto ctx = GetContextSwitchData( td->id ); if( ctx ) { -#ifdef NO_PARALLEL_SORT - pdqsort_branchless( td->postponedSamples.begin(), td->postponedSamples.end(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r.time.Val(); } ); -#else - std::sort( std::execution::par_unseq, td->postponedSamples.begin(), td->postponedSamples.end(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r.time.Val(); } ); -#endif + td->postponedSamples.ensure_sorted(); auto sit = td->postponedSamples.begin(); auto cit = std::lower_bound( ctx->v.begin(), ctx->v.end(), sit->time.Val(), [] ( const auto& l, const auto& r ) { return (uint64_t)l.End() < (uint64_t)r; } ); if( cit != ctx->v.end() )