Process memory pool discard events.

This commit is contained in:
Bartosz Taudul 2024-10-21 18:11:08 +02:00
parent cacd71c401
commit 872367f068
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 67 additions and 0 deletions

View File

@ -4625,6 +4625,12 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::MemFreeCallstackNamed:
ProcessMemFreeCallstackNamed( ev.memFree );
break;
case QueueType::MemDiscard:
ProcessMemDiscard( ev.memDiscard );
break;
case QueueType::MemDiscardCallstack:
ProcessMemDiscardCallstack( ev.memDiscard );
break;
case QueueType::CallstackSerial:
ProcessCallstackSerial();
break;
@ -6154,6 +6160,65 @@ void Worker::ProcessMemFreeCallstackNamed( const QueueMemFree& ev )
m_serialNextCallstack = 0;
}
void Worker::ProcessMemDiscard( const QueueMemDiscard& ev )
{
assert( m_memNamePayload == 0 );
auto it = m_data.memNameMap.find( ev.name );
if( it == m_data.memNameMap.end() ) return;
const auto refTime = RefTime( m_refTimeSerial, ev.time );
auto& memdata = *it->second;
const auto time = TscTime( refTime );
if( m_data.lastTime < time ) m_data.lastTime = time;
NoticeThread( ev.thread );
const auto thread = CompressThread( ev.thread );
for( auto& v : memdata.active )
{
memdata.frees.push_back( v.second );
auto& mem = memdata.data[v.second];
mem.SetTimeThreadFree( time, thread );
memdata.usage -= mem.Size();
MemAllocChanged( memdata, time );
}
memdata.active.clear();
assert( memdata.usage == 0 );
}
void Worker::ProcessMemDiscardCallstack( const QueueMemDiscard& ev )
{
assert( m_serialNextCallstack != 0 );
auto cs = m_serialNextCallstack;
m_serialNextCallstack = 0;
assert( m_memNamePayload == 0 );
auto it = m_data.memNameMap.find( ev.name );
if( it == m_data.memNameMap.end() ) return;
const auto refTime = RefTime( m_refTimeSerial, ev.time );
auto& memdata = *it->second;
const auto time = TscTime( refTime );
if( m_data.lastTime < time ) m_data.lastTime = time;
NoticeThread( ev.thread );
const auto thread = CompressThread( ev.thread );
for( auto& v : memdata.active )
{
memdata.frees.push_back( v.second );
auto& mem = memdata.data[v.second];
mem.SetTimeThreadFree( time, thread );
mem.csFree.SetVal( cs );
memdata.usage -= mem.Size();
MemAllocChanged( memdata, time );
}
memdata.active.clear();
assert( memdata.usage == 0 );
}
void Worker::ProcessCallstackSerial()
{
assert( m_pendingCallstackId != 0 );

View File

@ -745,10 +745,12 @@ private:
tracy_force_inline MemEvent* ProcessMemAllocNamed( const QueueMemAlloc& ev );
tracy_force_inline MemEvent* ProcessMemFree( const QueueMemFree& ev );
tracy_force_inline MemEvent* ProcessMemFreeNamed( const QueueMemFree& ev );
tracy_force_inline void ProcessMemDiscard( const QueueMemDiscard& ev );
tracy_force_inline void ProcessMemAllocCallstack( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemAllocCallstackNamed( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemFreeCallstack( const QueueMemFree& ev );
tracy_force_inline void ProcessMemFreeCallstackNamed( const QueueMemFree& ev );
tracy_force_inline void ProcessMemDiscardCallstack( const QueueMemDiscard& ev );
tracy_force_inline void ProcessCallstackSerial();
tracy_force_inline void ProcessCallstack();
tracy_force_inline void ProcessCallstackSample( const QueueCallstackSample& ev );