Skip to content

Commit 2f17e33

Browse files
wolfpldMarcos Slomp
andcommitted
Prevent duplicate callstack frame queries.
Callstack frames will now have nullptr as the value in the callstackFrameMap map, as a way to signal that a query for given key is already pending. Duplicate queries should no longer happen. @slomp provided alternative implementation, which produced the following results: Queries made: 195,778 Duplicate queries skipped: 9,518,910 Co-authored-by: Marcos Slomp <[email protected]>
1 parent c704f90 commit 2f17e33

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

server/TracyWorker.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,7 @@ void Worker::QueryCallstackFrame( uint64_t addr )
32033203
if( m_data.callstackFrameMap.contains( packed ) ) return;
32043204

32053205
m_pendingCallstackFrames++;
3206+
m_data.callstackFrameMap.emplace( packed, nullptr );
32063207
Query( ServerQueryCallstackFrame, addr );
32073208
}
32083209

@@ -6515,7 +6516,7 @@ void Worker::ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev )
65156516

65166517
// Frames may be duplicated due to recursion
65176518
auto fmit = m_data.callstackFrameMap.find( PackPointer( ev.ptr ) );
6518-
if( fmit == m_data.callstackFrameMap.end() )
6519+
if( !fmit->second )
65196520
{
65206521
m_callstackFrameStaging = m_slab.Alloc<CallstackFrameData>();
65216522
m_callstackFrameStaging->size = ev.size;
@@ -6628,8 +6629,10 @@ void Worker::ProcessCallstackFrame( const QueueCallstackFrame& ev, bool querySym
66286629

66296630
if( --m_pendingCallstackSubframes == 0 )
66306631
{
6631-
assert( m_data.callstackFrameMap.find( frameId ) == m_data.callstackFrameMap.end() );
6632-
m_data.callstackFrameMap.emplace( frameId, m_callstackFrameStaging );
6632+
auto fit = m_data.callstackFrameMap.find( frameId );
6633+
assert( fit != m_data.callstackFrameMap.end() );
6634+
assert( !fit->second );
6635+
fit->second = m_callstackFrameStaging;
66336636
m_data.codeSymbolMap.emplace( m_callstackFrameStagingPtr, m_callstackFrameStaging->data[0].symAddr );
66346637
m_callstackFrameStaging = nullptr;
66356638
}

0 commit comments

Comments
 (0)