From 46c70fcbb8d68dc56ff77ff33ee11d4d0a4a9cae Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 25 Jul 2026 21:32:48 +0200 Subject: [PATCH] Do not mark sorted vectors as unsorted on equal elements. SortedVector considered an appended element equal to the last one to break the ordering, marking the vector as unsorted. A non-decreasing sequence is sorted, so only a strictly smaller element has to trigger the marker. Equal keys are common: child sample vectors receive identical timestamps whenever a recursive call stack contains the same call site twice, which flipped the vectors to unsorted on virtually every recursive workload and caused the lazy sort in GetChildSamples to run over and over again while holding the data lock. The lazy sort machinery handles duplicate keys correctly, as both the prefix and tail merge windows are computed with lower bounds. --- server/TracySortedVector.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/TracySortedVector.hpp b/server/TracySortedVector.hpp index 5e1c34e0..dd4e2739 100644 --- a/server/TracySortedVector.hpp +++ b/server/TracySortedVector.hpp @@ -72,7 +72,7 @@ public: template tracy_force_inline void push_back( const T& val, Compare comp ) { - if( sortedEnd == 0 && !v.empty() && !comp( v.back(), val ) ) + if( sortedEnd == 0 && !v.empty() && comp( val, v.back() ) ) { sortedEnd = (uint32_t)v.size(); }