1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Store children vectors in a separate data collection.

This reduces per-zone memory cost by 9 bytes if there are no children
and increases it by 4 bytes, if there are children. This is universally
a better solution, as the following data shows:

+++ /home/wolf/desktop/tracy-old/android.tracy +++
Vectors: 2794480
Size 0: 2373070 (84.92%)
Size 1: 70237 (2.51%)
Size 2+: 351173 (12.57%)
+++ /home/wolf/desktop/tracy-old/asset-new.tracy +++
Vectors: 1799227
Size 0: 1482691 (82.41%)
Size 1: 93272 (5.18%)
Size 2+: 223264 (12.41%)
+++ /home/wolf/desktop/tracy-old/asset-new-id.tracy +++
Vectors: 1977996
Size 0: 1640817 (82.95%)
Size 1: 97198 (4.91%)
Size 2+: 239981 (12.13%)
+++ /home/wolf/desktop/tracy-old/asset-old.tracy +++
Vectors: 1782395
Size 0: 1471437 (82.55%)
Size 1: 88813 (4.98%)
Size 2+: 222145 (12.46%)
+++ /home/wolf/desktop/tracy-old/big.tracy +++
Vectors: 180794047
Size 0: 172696094 (95.52%)
Size 1: 2799772 (1.55%)
Size 2+: 5298181 (2.93%)
+++ /home/wolf/desktop/tracy-old/darkrl.tracy +++
Vectors: 12014129
Size 0: 11611324 (96.65%)
Size 1: 134980 (1.12%)
Size 2+: 267825 (2.23%)
+++ /home/wolf/desktop/tracy-old/mem.tracy +++
Vectors: 383097
Size 0: 321932 (84.03%)
Size 1: 854 (0.22%)
Size 2+: 60311 (15.74%)
+++ /home/wolf/desktop/tracy-old/new.tracy +++
Vectors: 77536
Size 0: 63035 (81.30%)
Size 1: 8886 (11.46%)
Size 2+: 5615 (7.24%)
+++ /home/wolf/desktop/tracy-old/selfprofile.tracy +++
Vectors: 22940871
Size 0: 22704868 (98.97%)
Size 1: 73000 (0.32%)
Size 2+: 163003 (0.71%)
+++ /home/wolf/desktop/tracy-old/tbrowser.tracy +++
Vectors: 962682
Size 0: 695380 (72.23%)
Size 1: 43007 (4.47%)
Size 2+: 224295 (23.30%)
+++ /home/wolf/desktop/tracy-old/virtualfile_hc.tracy +++
Vectors: 529170
Size 0: 449386 (84.92%)
Size 1: 15694 (2.97%)
Size 2+: 64090 (12.11%)
+++ /home/wolf/desktop/tracy-old/zfile_hc.tracy +++
Vectors: 264849
Size 0: 220589 (83.29%)
Size 1: 9386 (3.54%)
Size 2+: 34874 (13.17%)
This commit is contained in:
Bartosz Taudul
2018-07-22 16:05:50 +02:00
parent eb1475ebd4
commit 3a934b2ba3
4 changed files with 95 additions and 48 deletions
+21 -20
View File
@@ -1370,9 +1370,9 @@ int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
m_lastCpu = ev.cpu_start;
}
if( !ev.child.empty() )
if( ev.child >= 0 )
{
const auto d = DispatchZoneLevel( ev.child, hover, pxns, wpos, _offset, depth, yMin, yMax );
const auto d = DispatchZoneLevel( m_worker.GetZoneChildren( ev.child ), hover, pxns, wpos, _offset, depth, yMin, yMax );
if( d > maxdepth ) maxdepth = d;
}
@@ -1491,9 +1491,9 @@ int View::SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
{
m_lastCpu = ev.cpu_start;
if( !ev.child.empty() )
if( ev.child >= 0 )
{
const auto d = DispatchZoneLevel( ev.child, hover, pxns, wpos, _offset, depth, yMin, yMax );
const auto d = DispatchZoneLevel( m_worker.GetZoneChildren( ev.child ), hover, pxns, wpos, _offset, depth, yMin, yMax );
if( d > maxdepth ) maxdepth = d;
}
@@ -3187,26 +3187,27 @@ void View::DrawZoneInfoWindow()
}
} );
if( !ev.child.empty() )
if( ev.child >= 0 )
{
const auto& children = m_worker.GetZoneChildren( ev.child );
bool expand = ImGui::TreeNode( "Child zones" );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( ev.child.size(), true ) );
ImGui::TextDisabled( "(%s)", RealToString( children.size(), true ) );
if( expand )
{
auto ctt = std::make_unique<uint64_t[]>( ev.child.size() );
auto cti = std::make_unique<uint32_t[]>( ev.child.size() );
auto ctt = std::make_unique<uint64_t[]>( children.size() );
auto cti = std::make_unique<uint32_t[]>( children.size() );
uint64_t ctime = 0;
for( size_t i=0; i<ev.child.size(); i++ )
for( size_t i=0; i<children.size(); i++ )
{
const auto cend = m_worker.GetZoneEnd( *ev.child[i] );
const auto ct = cend - ev.child[i]->start;
const auto cend = m_worker.GetZoneEnd( *children[i] );
const auto ct = cend - children[i]->start;
ctime += ct;
ctt[i] = ct;
cti[i] = uint32_t( i );
}
pdqsort_branchless( cti.get(), cti.get() + ev.child.size(), [&ctt] ( const auto& lhs, const auto& rhs ) { return ctt[lhs] > ctt[rhs]; } );
pdqsort_branchless( cti.get(), cti.get() + children.size(), [&ctt] ( const auto& lhs, const auto& rhs ) { return ctt[lhs] > ctt[rhs]; } );
const auto ty = ImGui::GetTextLineHeight();
ImGui::Columns( 2 );
@@ -3216,9 +3217,9 @@ void View::DrawZoneInfoWindow()
sprintf( buf, "%s (%.2f%%)", TimeToString( ztime - ctime ), double( ztime - ctime ) / ztime * 100 );
ImGui::ProgressBar( double( ztime - ctime ) / ztime, ImVec2( -1, ty ), buf );
ImGui::NextColumn();
for( size_t i=0; i<ev.child.size(); i++ )
for( size_t i=0; i<children.size(); i++ )
{
auto& cev = *ev.child[cti[i]];
auto& cev = *children[cti[i]];
const auto txt = m_worker.GetZoneName( cev );
bool b = false;
ImGui::PushID( (int)i );
@@ -6207,9 +6208,9 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
if( it != timeline->begin() ) --it;
if( zone.end >= 0 && (*it)->start > zone.end ) break;
if( *it == &zone ) return parent;
if( (*it)->child.empty() ) break;
if( (*it)->child < 0 ) break;
parent = *it;
timeline = &parent->child;
timeline = &m_worker.GetZoneChildren( parent->child );
}
}
return nullptr;
@@ -6248,8 +6249,8 @@ uint64_t View::GetZoneThread( const ZoneEvent& zone ) const
if( it != timeline->begin() ) --it;
if( zone.end >= 0 && (*it)->start > zone.end ) break;
if( *it == &zone ) return thread->id;
if( (*it)->child.empty() ) break;
timeline = &(*it)->child;
if( (*it)->child < 0 ) break;
timeline = &m_worker.GetZoneChildren( (*it)->child );
}
}
return 0;
@@ -6323,8 +6324,8 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
if( it != timeline->begin() ) --it;
if( (*it)->start > time || ( (*it)->end >= 0 && (*it)->end < time ) ) return ret;
ret = *it;
if( (*it)->child.empty() ) return ret;
timeline = &(*it)->child;
if( (*it)->child < 0 ) return ret;
timeline = &m_worker.GetZoneChildren( (*it)->child );
}
}