Force inline GetZoneEnd's fast exit path.

This commit is contained in:
Bartosz Taudul 2023-05-01 01:28:32 +02:00
parent 2e9d8f8215
commit 5019f7d2b4
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 11 additions and 6 deletions

View File

@ -2313,12 +2313,12 @@ const uint64_t* Worker::GetInlineSymbolList( uint64_t sym, uint32_t len )
return it;
}
int64_t Worker::GetZoneEnd( const ZoneEvent& ev )
int64_t Worker::GetZoneEndImpl( const ZoneEvent& ev )
{
assert( !ev.IsEndValid() );
auto ptr = &ev;
for(;;)
{
if( ptr->IsEndValid() ) return ptr->End();
if( !ptr->HasChildren() ) return ptr->Start();
auto& children = GetZoneChildren( ptr->Child() );
if( children.is_magic() )
@ -2330,15 +2330,16 @@ int64_t Worker::GetZoneEnd( const ZoneEvent& ev )
{
ptr = children.back();
}
if( ptr->IsEndValid() ) return ptr->End();
}
}
int64_t Worker::GetZoneEnd( const GpuEvent& ev )
int64_t Worker::GetZoneEndImpl( const GpuEvent& ev )
{
assert( ev.GpuEnd() < 0 );
auto ptr = &ev;
for(;;)
{
if( ptr->GpuEnd() >= 0 ) return ptr->GpuEnd();
if( ptr->Child() < 0 ) return ptr->GpuStart() >= 0 ? ptr->GpuStart() : m_data.lastTime;
auto& children = GetGpuChildren( ptr->Child() );
if( children.is_magic() )
@ -2350,6 +2351,7 @@ int64_t Worker::GetZoneEnd( const GpuEvent& ev )
{
ptr = children.back();
}
if( ptr->GpuEnd() >= 0 ) return ptr->GpuEnd();
}
}

View File

@ -562,8 +562,8 @@ public:
// GetZoneEnd() will try to infer the end time by looking at child zones (parent zone can't end
// before its children have ended).
// GetZoneEndDirect() will only return zone's direct timing data, without looking at children.
int64_t GetZoneEnd( const ZoneEvent& ev );
int64_t GetZoneEnd( const GpuEvent& ev );
tracy_force_inline int64_t GetZoneEnd( const ZoneEvent& ev ) { return ev.IsEndValid() ? ev.End() : GetZoneEndImpl( ev ); }
tracy_force_inline int64_t GetZoneEnd( const GpuEvent& ev ) { return ev.GpuEnd() >= 0 ? ev.GpuEnd() : GetZoneEndImpl( ev ); }
static tracy_force_inline int64_t GetZoneEndDirect( const ZoneEvent& ev ) { return ev.IsEndValid() ? ev.End() : ev.Start(); }
static tracy_force_inline int64_t GetZoneEndDirect( const GpuEvent& ev ) { return ev.GpuEnd() >= 0 ? ev.GpuEnd() : ev.GpuStart(); }
@ -929,6 +929,9 @@ private:
tracy_force_inline ZoneExtra& AllocZoneExtra( ZoneEvent& ev );
tracy_force_inline ZoneExtra& RequestZoneExtra( ZoneEvent& ev );
int64_t GetZoneEndImpl( const ZoneEvent& ev );
int64_t GetZoneEndImpl( const GpuEvent& ev );
void UpdateMbps( int64_t td );
int64_t ReadTimeline( FileRead& f, Vector<short_ptr<ZoneEvent>>& vec, uint32_t size, int64_t refTime, int32_t& childIdx );