mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Only enable magic fitted vectors in no-statistics builds.
Source location zones pointer fixup is just too slow to be feasible. Note: no-statistics builds of the graphical profiler don't perform fixup of view-related pointers (e.g. zone info window zone pointer). This won't cause crashes, because the pointers are still valid, but the displayed data will be incorrect and potentially changing in time, as the pointer can be reused for completely other zone. Memory usage of ToyPathTracer data, in various scenarios: Capture + statistics: 7121 MB Load + statistics: 6057 MB Capture - statistics: 4876 MB Load - statistics: 4521 MB
This commit is contained in:
parent
e1e3bbbe3e
commit
b946c1d39e
@ -2834,16 +2834,8 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread )
|
||||
{
|
||||
m_data.zonesCnt++;
|
||||
|
||||
auto td = m_threadCtxData;
|
||||
if( !td ) td = m_threadCtxData = NoticeThread( thread );
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
auto slz = GetSourceLocationZones( zone->SrcLoc() );
|
||||
if( !td->stack.empty() )
|
||||
{
|
||||
assert( m_slzPointerMap.find( zone ) == m_slzPointerMap.end() );
|
||||
m_slzPointerMap.emplace( zone, slz->zones.size() );
|
||||
}
|
||||
auto& ztd = slz->zones.push_next();
|
||||
ztd.SetZone( zone );
|
||||
ztd.SetThread( CompressThread( thread ) );
|
||||
@ -2851,6 +2843,8 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread )
|
||||
CountZoneStatistics( zone );
|
||||
#endif
|
||||
|
||||
auto td = m_threadCtxData;
|
||||
if( !td ) td = m_threadCtxData = NoticeThread( thread );
|
||||
td->count++;
|
||||
if( td->stack.empty() )
|
||||
{
|
||||
@ -3556,6 +3550,9 @@ void Worker::ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev )
|
||||
ZoneEvent* Worker::AllocZoneEvent()
|
||||
{
|
||||
ZoneEvent* ret;
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
ret = m_slab.Alloc<ZoneEvent>();
|
||||
#else
|
||||
if( m_zoneEventPool.empty() )
|
||||
{
|
||||
ret = m_slab.Alloc<ZoneEvent>();
|
||||
@ -3564,6 +3561,7 @@ ZoneEvent* Worker::AllocZoneEvent()
|
||||
{
|
||||
ret = m_zoneEventPool.back_and_pop();
|
||||
}
|
||||
#endif
|
||||
memset( &ret->text, 0, sizeof( ZoneEvent::text ) + sizeof( ZoneEvent::callstack ) + sizeof( ZoneEvent::name ) );
|
||||
return ret;
|
||||
}
|
||||
@ -3653,6 +3651,10 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
||||
if( sz <= 8 * 1024 )
|
||||
{
|
||||
Vector<short_ptr<ZoneEvent>> fitVec;
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
fitVec.reserve_exact( sz, m_slab );
|
||||
memcpy( fitVec.data(), childVec.data(), sz * sizeof( short_ptr<ZoneEvent> ) );
|
||||
#else
|
||||
fitVec.set_magic();
|
||||
auto& fv = *((Vector<ZoneEvent>*)&fitVec);
|
||||
fv.reserve_exact( sz, m_slab );
|
||||
@ -3660,28 +3662,13 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
||||
for( auto& ze : childVec )
|
||||
{
|
||||
ZoneEvent* src = ze;
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
auto slz = GetSourceLocationZones( src->SrcLoc() );
|
||||
auto slzit = m_slzPointerMap.find( src );
|
||||
assert( slzit != m_slzPointerMap.end() );
|
||||
slz->zones[slzit->second].SetZone( dst );
|
||||
m_slzPointerMap.erase( slzit );
|
||||
#endif
|
||||
memcpy( dst++, src, sizeof( ZoneEvent ) );
|
||||
m_zoneEventPool.push_back( src );
|
||||
}
|
||||
#endif
|
||||
fitVec.swap( childVec );
|
||||
m_data.zoneVectorCache.push_back( std::move( fitVec ) );
|
||||
}
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
else
|
||||
{
|
||||
for( auto& z : childVec )
|
||||
{
|
||||
m_slzPointerMap.erase( z );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
|
@ -702,10 +702,8 @@ private:
|
||||
std::mutex m_netWriteLock;
|
||||
std::condition_variable m_netWriteCv;
|
||||
|
||||
#ifdef TRACY_NO_STATISTICS
|
||||
Vector<ZoneEvent*> m_zoneEventPool;
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
flat_hash_map<ZoneEvent*, size_t, nohash<ZoneEvent*>> m_slzPointerMap;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user