mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Process all data available in ring buffers.
This commit is contained in:
parent
5b7cd06840
commit
ca2130d56c
@ -59,12 +59,6 @@ public:
|
|||||||
ioctl( m_fd, PERF_EVENT_IOC_ENABLE, 0 );
|
ioctl( m_fd, PERF_EVENT_IOC_ENABLE, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasData() const
|
|
||||||
{
|
|
||||||
const auto head = LoadHead();
|
|
||||||
return head > m_tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Read( void* dst, uint64_t offset, uint64_t cnt )
|
void Read( void* dst, uint64_t offset, uint64_t cnt )
|
||||||
{
|
{
|
||||||
auto src = ( m_tail + offset ) % Size;
|
auto src = ( m_tail + offset ) % Size;
|
||||||
@ -100,12 +94,17 @@ public:
|
|||||||
return ( quot << m_metadata->time_shift ) + ( rem << m_metadata->time_shift ) / m_metadata->time_mult;
|
return ( quot << m_metadata->time_shift ) + ( rem << m_metadata->time_shift ) / m_metadata->time_mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
uint64_t LoadHead() const
|
uint64_t LoadHead() const
|
||||||
{
|
{
|
||||||
return std::atomic_load_explicit( (const volatile std::atomic<uint64_t>*)&m_metadata->data_head, std::memory_order_acquire );
|
return std::atomic_load_explicit( (const volatile std::atomic<uint64_t>*)&m_metadata->data_head, std::memory_order_acquire );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t GetTail() const
|
||||||
|
{
|
||||||
|
return m_tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
void StoreTail()
|
void StoreTail()
|
||||||
{
|
{
|
||||||
std::atomic_store_explicit( (volatile std::atomic<uint64_t>*)&m_metadata->data_tail, m_tail, std::memory_order_release );
|
std::atomic_store_explicit( (volatile std::atomic<uint64_t>*)&m_metadata->data_tail, m_tail, std::memory_order_release );
|
||||||
|
|||||||
@ -933,14 +933,21 @@ static void SetupSampling( int64_t& samplingPeriod )
|
|||||||
for( int i=0; i<s_numBuffers; i++ )
|
for( int i=0; i<s_numBuffers; i++ )
|
||||||
{
|
{
|
||||||
if( !traceActive.load( std::memory_order_relaxed ) ) break;
|
if( !traceActive.load( std::memory_order_relaxed ) ) break;
|
||||||
if( !s_ring[i].HasData() ) continue;
|
const auto head = s_ring[i].LoadHead();
|
||||||
|
const auto tail = s_ring[i].GetTail();
|
||||||
|
if( head == tail ) continue;
|
||||||
|
assert( head > tail );
|
||||||
hadData = true;
|
hadData = true;
|
||||||
|
|
||||||
|
const auto end = head - tail;
|
||||||
|
uint64_t pos = 0;
|
||||||
|
while( pos < end )
|
||||||
|
{
|
||||||
perf_event_header hdr;
|
perf_event_header hdr;
|
||||||
s_ring[i].Read( &hdr, 0, sizeof( perf_event_header ) );
|
s_ring[i].Read( &hdr, pos, sizeof( perf_event_header ) );
|
||||||
if( hdr.type == PERF_RECORD_SAMPLE )
|
if( hdr.type == PERF_RECORD_SAMPLE )
|
||||||
{
|
{
|
||||||
auto offset = sizeof( perf_event_header );
|
auto offset = pos + sizeof( perf_event_header );
|
||||||
const auto id = s_ring[i].GetId();
|
const auto id = s_ring[i].GetId();
|
||||||
if( id == EventCallstack )
|
if( id == EventCallstack )
|
||||||
{
|
{
|
||||||
@ -1068,7 +1075,10 @@ static void SetupSampling( int64_t& samplingPeriod )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s_ring[i].Advance( hdr.size );
|
pos += hdr.size;
|
||||||
|
}
|
||||||
|
assert( pos == end );
|
||||||
|
s_ring[i].Advance( end );
|
||||||
}
|
}
|
||||||
if( !traceActive.load( std::memory_order_relaxed) ) break;
|
if( !traceActive.load( std::memory_order_relaxed) ) break;
|
||||||
if( !hadData )
|
if( !hadData )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user