mirror of
https://github.com/wolfpld/tracy
synced 2025-05-02 21:53:52 +00:00
Create memory plot based on memory alloc/free events.
This commit is contained in:
parent
cd34ed6968
commit
d8bfe7de2e
@ -236,6 +236,7 @@ struct MemData
|
|||||||
uint64_t high = std::numeric_limits<uint64_t>::min();
|
uint64_t high = std::numeric_limits<uint64_t>::min();
|
||||||
uint64_t low = std::numeric_limits<uint64_t>::max();
|
uint64_t low = std::numeric_limits<uint64_t>::max();
|
||||||
uint64_t usage = 0;
|
uint64_t usage = 0;
|
||||||
|
PlotData* plot = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StringLocation
|
struct StringLocation
|
||||||
|
@ -1853,17 +1853,52 @@ void Worker::ProcessMemAlloc( const QueueMemAlloc& ev )
|
|||||||
m_data.memory.low = std::min( low, ptr );
|
m_data.memory.low = std::min( low, ptr );
|
||||||
m_data.memory.high = std::max( high, ptrend );
|
m_data.memory.high = std::max( high, ptrend );
|
||||||
m_data.memory.usage += size;
|
m_data.memory.usage += size;
|
||||||
|
|
||||||
|
MemAllocChanged( time );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::ProcessMemFree( const QueueMemFree& ev )
|
void Worker::ProcessMemFree( const QueueMemFree& ev )
|
||||||
{
|
{
|
||||||
|
const auto time = TscTime( ev.time );
|
||||||
|
|
||||||
auto it = m_data.memory.active.find( ev.ptr );
|
auto it = m_data.memory.active.find( ev.ptr );
|
||||||
assert( it != m_data.memory.active.end() );
|
assert( it != m_data.memory.active.end() );
|
||||||
auto& mem = m_data.memory.data[it->second];
|
auto& mem = m_data.memory.data[it->second];
|
||||||
mem.timeFree = TscTime( ev.time );
|
mem.timeFree = time;
|
||||||
mem.threadFree = CompressThread( ev.thread );
|
mem.threadFree = CompressThread( ev.thread );
|
||||||
m_data.memory.usage -= mem.size;
|
m_data.memory.usage -= mem.size;
|
||||||
m_data.memory.active.erase( it );
|
m_data.memory.active.erase( it );
|
||||||
|
|
||||||
|
MemAllocChanged( time );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::MemAllocChanged( int64_t time )
|
||||||
|
{
|
||||||
|
const auto val = (double)m_data.memory.usage;
|
||||||
|
if( !m_data.memory.plot )
|
||||||
|
{
|
||||||
|
CreateMemAllocPlot();
|
||||||
|
m_data.memory.plot->min = val;
|
||||||
|
m_data.memory.plot->max = val;
|
||||||
|
m_data.memory.plot->data.push_back( { time, val } );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert( !m_data.memory.plot->data.empty() );
|
||||||
|
assert( m_data.memory.plot->data.back().time <= time );
|
||||||
|
if( m_data.memory.plot->min > val ) m_data.memory.plot->min = val;
|
||||||
|
else if( m_data.memory.plot->max < val ) m_data.memory.plot->max = val;
|
||||||
|
m_data.memory.plot->data.push_back_non_empty( { time, val } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::CreateMemAllocPlot()
|
||||||
|
{
|
||||||
|
assert( !m_data.memory.plot );
|
||||||
|
m_data.memory.plot = m_slab.AllocInit<PlotData>();
|
||||||
|
m_data.memory.plot->name = 0;
|
||||||
|
m_data.memory.plot->type = PlotType::Memory;
|
||||||
|
m_data.plots.push_back( m_data.memory.plot );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread )
|
void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread )
|
||||||
|
@ -208,6 +208,9 @@ private:
|
|||||||
tracy_force_inline uint32_t ShrinkSourceLocation( uint64_t srcloc );
|
tracy_force_inline uint32_t ShrinkSourceLocation( uint64_t srcloc );
|
||||||
uint32_t NewShrinkedSourceLocation( uint64_t srcloc );
|
uint32_t NewShrinkedSourceLocation( uint64_t srcloc );
|
||||||
|
|
||||||
|
tracy_force_inline void MemAllocChanged( int64_t time );
|
||||||
|
void CreateMemAllocPlot();
|
||||||
|
|
||||||
void InsertMessageData( MessageData* msg, uint64_t thread );
|
void InsertMessageData( MessageData* msg, uint64_t thread );
|
||||||
|
|
||||||
ThreadData* NewThread( uint64_t thread );
|
ThreadData* NewThread( uint64_t thread );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user