1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 12:53:51 +00:00

Move ring identifier check out of the loop.

This commit is contained in:
Bartosz Taudul 2022-06-16 13:48:15 +02:00
parent 145e3e213a
commit aee8336847
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1150,9 +1150,10 @@ void SysTraceWorker( void* ptr )
const auto id = ring.GetId(); const auto id = ring.GetId();
assert( id != EventContextSwitch ); assert( id != EventContextSwitch );
const auto end = head - tail; const auto end = head - tail;
uint64_t pos = 0; uint64_t pos = 0;
if( id == EventCallstack )
{
while( pos < end ) while( pos < end )
{ {
perf_event_header hdr; perf_event_header hdr;
@ -1160,8 +1161,7 @@ void SysTraceWorker( void* ptr )
if( hdr.type == PERF_RECORD_SAMPLE ) if( hdr.type == PERF_RECORD_SAMPLE )
{ {
auto offset = pos + sizeof( perf_event_header ); auto offset = pos + sizeof( perf_event_header );
if( id == EventCallstack )
{
// Layout: // Layout:
// u32 pid, tid // u32 pid, tid
// u64 time // u64 time
@ -1194,8 +1194,19 @@ void SysTraceWorker( void* ptr )
TracyLfqCommit; TracyLfqCommit;
} }
} }
pos += hdr.size;
}
}
else else
{ {
while( pos < end )
{
perf_event_header hdr;
ring.Read( &hdr, pos, sizeof( perf_event_header ) );
if( hdr.type == PERF_RECORD_SAMPLE )
{
auto offset = pos + sizeof( perf_event_header );
// Layout: // Layout:
// u64 ip // u64 ip
// u64 time // u64 time
@ -1239,9 +1250,9 @@ void SysTraceWorker( void* ptr )
MemWrite( &item->hwSample.time, t0 ); MemWrite( &item->hwSample.time, t0 );
TracyLfqCommit; TracyLfqCommit;
} }
}
pos += hdr.size; pos += hdr.size;
} }
}
assert( pos == end ); assert( pos == end );
ring.Advance( end ); ring.Advance( end );
} }