mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-14 04:01:48 +00:00
Save 2 bytes in ContextSwitchData and ContextSwitchCpu.
This commit is contained in:
parent
99d198d0bf
commit
ae4794ab4c
@ -108,6 +108,32 @@ private:
|
|||||||
uint8_t m_val[3];
|
uint8_t m_val[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Int48
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
tracy_force_inline Int48() { memset( m_val, 0, sizeof( m_val ) ); }
|
||||||
|
tracy_force_inline Int48( int64_t val )
|
||||||
|
{
|
||||||
|
SetVal( val );
|
||||||
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void SetVal( int64_t val )
|
||||||
|
{
|
||||||
|
memcpy( m_val, &val, 6 );
|
||||||
|
}
|
||||||
|
|
||||||
|
tracy_force_inline int64_t Val() const
|
||||||
|
{
|
||||||
|
int64_t val = 0;
|
||||||
|
memcpy( ((char*)&val)+2, m_val, 6 );
|
||||||
|
val >>= 16;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t m_val[6];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct SourceLocation
|
struct SourceLocation
|
||||||
{
|
{
|
||||||
@ -312,10 +338,12 @@ struct ContextSwitchData
|
|||||||
tracy_force_inline void SetReason( int8_t reason ) { memcpy( ((char*)&_end_reason_state)+1, &reason, 1 ); }
|
tracy_force_inline void SetReason( int8_t reason ) { memcpy( ((char*)&_end_reason_state)+1, &reason, 1 ); }
|
||||||
tracy_force_inline int8_t State() const { return int8_t( _end_reason_state & 0xFF ); }
|
tracy_force_inline int8_t State() const { return int8_t( _end_reason_state & 0xFF ); }
|
||||||
tracy_force_inline void SetState( int8_t state ) { memcpy( &_end_reason_state, &state, 1 ); }
|
tracy_force_inline void SetState( int8_t state ) { memcpy( &_end_reason_state, &state, 1 ); }
|
||||||
|
tracy_force_inline int64_t WakeupVal() const { return _wakeup.Val(); }
|
||||||
|
tracy_force_inline void SetWakeup( int64_t wakeup ) { assert( wakeup < (int64_t)( 1ull << 47 ) ); _wakeup.SetVal( wakeup ); }
|
||||||
|
|
||||||
uint64_t _start_cpu;
|
uint64_t _start_cpu;
|
||||||
uint64_t _end_reason_state;
|
uint64_t _end_reason_state;
|
||||||
int64_t wakeup;
|
Int48 _wakeup;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) };
|
enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) };
|
||||||
@ -325,13 +353,13 @@ struct ContextSwitchCpu
|
|||||||
{
|
{
|
||||||
tracy_force_inline int64_t Start() const { return int64_t( _start_thread ) >> 16; }
|
tracy_force_inline int64_t Start() const { return int64_t( _start_thread ) >> 16; }
|
||||||
tracy_force_inline void SetStart( int64_t start ) { assert( start < (int64_t)( 1ull << 47 ) ); memcpy( ((char*)&_start_thread)+2, &start, 4 ); memcpy( ((char*)&_start_thread)+6, ((char*)&start)+4, 2 ); }
|
tracy_force_inline void SetStart( int64_t start ) { assert( start < (int64_t)( 1ull << 47 ) ); memcpy( ((char*)&_start_thread)+2, &start, 4 ); memcpy( ((char*)&_start_thread)+6, ((char*)&start)+4, 2 ); }
|
||||||
tracy_force_inline int64_t End() const { return _end; }
|
tracy_force_inline int64_t End() const { return _end.Val(); }
|
||||||
tracy_force_inline void SetEnd( int64_t end ) { assert( end < (int64_t)( 1ull << 47 ) ); _end = end; }
|
tracy_force_inline void SetEnd( int64_t end ) { assert( end < (int64_t)( 1ull << 47 ) ); _end.SetVal( end ); }
|
||||||
tracy_force_inline uint16_t Thread() const { return uint16_t( _start_thread ); }
|
tracy_force_inline uint16_t Thread() const { return uint16_t( _start_thread ); }
|
||||||
tracy_force_inline void SetThread( uint16_t thread ) { memcpy( &_start_thread, &thread, 2 ); }
|
tracy_force_inline void SetThread( uint16_t thread ) { memcpy( &_start_thread, &thread, 2 ); }
|
||||||
|
|
||||||
uint64_t _start_thread;
|
uint64_t _start_thread;
|
||||||
uint64_t _end;
|
Int48 _end;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { ContextSwitchCpuSize = sizeof( ContextSwitchCpu ) };
|
enum { ContextSwitchCpuSize = sizeof( ContextSwitchCpu ) };
|
||||||
|
@ -2855,7 +2855,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
|
|||||||
{
|
{
|
||||||
const bool migration = pit->Cpu() != ev.Cpu();
|
const bool migration = pit->Cpu() != ev.Cpu();
|
||||||
const auto px0 = std::max( { ( pit->End() - m_vd.zvStart ) * pxns, -10.0, minpx } );
|
const auto px0 = std::max( { ( pit->End() - m_vd.zvStart ) * pxns, -10.0, minpx } );
|
||||||
const auto pxw = ( ev.wakeup - m_vd.zvStart ) * pxns;
|
const auto pxw = ( ev.WakeupVal() - m_vd.zvStart ) * pxns;
|
||||||
const auto px1 = std::min( ( ev.Start() - m_vd.zvStart ) * pxns, w + 10.0 );
|
const auto px1 = std::min( ( ev.Start() - m_vd.zvStart ) * pxns, w + 10.0 );
|
||||||
const auto color = migration ? 0xFFEE7711 : 0xFF2222AA;
|
const auto color = migration ? 0xFFEE7711 : 0xFF2222AA;
|
||||||
if( m_vd.darkenContextSwitches )
|
if( m_vd.darkenContextSwitches )
|
||||||
@ -2863,7 +2863,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
|
|||||||
draw->AddRectFilled( wpos + ImVec2( px0, round( offset + ty * 0.5 ) ), wpos + ImVec2( px1, endOffset ), 0x661C2321 );
|
draw->AddRectFilled( wpos + ImVec2( px0, round( offset + ty * 0.5 ) ), wpos + ImVec2( px1, endOffset ), 0x661C2321 );
|
||||||
}
|
}
|
||||||
draw->AddLine( wpos + ImVec2( px0, round( offset + ty * 0.5 ) - 0.5 ), wpos + ImVec2( std::min( pxw, w+10.0 ), round( offset + ty * 0.5 ) - 0.5 ), color, 2 );
|
draw->AddLine( wpos + ImVec2( px0, round( offset + ty * 0.5 ) - 0.5 ), wpos + ImVec2( std::min( pxw, w+10.0 ), round( offset + ty * 0.5 ) - 0.5 ), color, 2 );
|
||||||
if( ev.wakeup != ev.Start() )
|
if( ev.WakeupVal() != ev.Start() )
|
||||||
{
|
{
|
||||||
draw->AddLine( wpos + ImVec2( std::max( pxw, 10.0 ), round( offset + ty * 0.5 ) - 0.5 ), wpos + ImVec2( px1, round( offset + ty * 0.5 ) - 0.5 ), 0xFF2280A0, 2 );
|
draw->AddLine( wpos + ImVec2( std::max( pxw, 10.0 ), round( offset + ty * 0.5 ) - 0.5 ), wpos + ImVec2( px1, round( offset + ty * 0.5 ) - 0.5 ), 0xFF2280A0, 2 );
|
||||||
}
|
}
|
||||||
@ -2874,7 +2874,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
|
|||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
TextFocused( "Thread is", migration ? "migrating CPUs" : "waiting" );
|
TextFocused( "Thread is", migration ? "migrating CPUs" : "waiting" );
|
||||||
TextFocused( "Waiting time:", TimeToString( ev.wakeup - pit->End() ) );
|
TextFocused( "Waiting time:", TimeToString( ev.WakeupVal() - pit->End() ) );
|
||||||
if( migration )
|
if( migration )
|
||||||
{
|
{
|
||||||
TextFocused( "CPU:", RealToString( pit->Cpu(), true ) );
|
TextFocused( "CPU:", RealToString( pit->Cpu(), true ) );
|
||||||
@ -2902,18 +2902,18 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
|
|||||||
|
|
||||||
if( ImGui::IsMouseClicked( 2 ) )
|
if( ImGui::IsMouseClicked( 2 ) )
|
||||||
{
|
{
|
||||||
ZoomToRange( pit->End(), ev.wakeup );
|
ZoomToRange( pit->End(), ev.WakeupVal() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( ev.wakeup != ev.Start() && ImGui::IsMouseHoveringRect( wpos + ImVec2( pxw, offset ), wpos + ImVec2( px1, offset + ty ) ) )
|
else if( ev.WakeupVal() != ev.Start() && ImGui::IsMouseHoveringRect( wpos + ImVec2( pxw, offset ), wpos + ImVec2( px1, offset + ty ) ) )
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
TextFocused( "Thread is", "waking up" );
|
TextFocused( "Thread is", "waking up" );
|
||||||
TextFocused( "Scheduling delay:", TimeToString( ev.Start() - ev.wakeup ) );
|
TextFocused( "Scheduling delay:", TimeToString( ev.Start() - ev.WakeupVal() ) );
|
||||||
TextFocused( "CPU:", RealToString( ev.Cpu(), true ) );
|
TextFocused( "CPU:", RealToString( ev.Cpu(), true ) );
|
||||||
if( ImGui::IsMouseClicked( 2 ) )
|
if( ImGui::IsMouseClicked( 2 ) )
|
||||||
{
|
{
|
||||||
ZoomToRange( pit->End(), ev.wakeup );
|
ZoomToRange( pit->End(), ev.WakeupVal() );
|
||||||
}
|
}
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
@ -5751,7 +5751,7 @@ void View::DrawZoneInfoWindow()
|
|||||||
const auto cpu0 = bit->Cpu();
|
const auto cpu0 = bit->Cpu();
|
||||||
++bit;
|
++bit;
|
||||||
const auto cstart = bit->Start();
|
const auto cstart = bit->Start();
|
||||||
const auto cwakeup = bit->wakeup;
|
const auto cwakeup = bit->WakeupVal();
|
||||||
const auto cpu1 = bit->Cpu();
|
const auto cpu1 = bit->Cpu();
|
||||||
|
|
||||||
if( ImGui::Selectable( TimeToString( cend - adjust ) ) )
|
if( ImGui::Selectable( TimeToString( cend - adjust ) ) )
|
||||||
|
@ -1631,7 +1631,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
|||||||
auto ptr = data->v.data();
|
auto ptr = data->v.data();
|
||||||
for( uint64_t j=0; j<csz; j++ )
|
for( uint64_t j=0; j<csz; j++ )
|
||||||
{
|
{
|
||||||
ptr->wakeup = ReadTimeOffset( f, refTime );
|
ptr->SetWakeup( ReadTimeOffset( f, refTime ) );
|
||||||
ptr->SetStart( ReadTimeOffset( f, refTime ) );
|
ptr->SetStart( ReadTimeOffset( f, refTime ) );
|
||||||
int64_t diff;
|
int64_t diff;
|
||||||
f.Read( diff );
|
f.Read( diff );
|
||||||
@ -4656,7 +4656,7 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
|
|||||||
migration = data.back().Cpu() != ev.cpu;
|
migration = data.back().Cpu() != ev.cpu;
|
||||||
}
|
}
|
||||||
item = &data.push_next();
|
item = &data.push_next();
|
||||||
item->wakeup = time;
|
item->SetWakeup( time );
|
||||||
}
|
}
|
||||||
item->SetStart( time );
|
item->SetStart( time );
|
||||||
item->SetEnd( -1 );
|
item->SetEnd( -1 );
|
||||||
@ -4699,7 +4699,7 @@ void Worker::ProcessThreadWakeup( const QueueThreadWakeup& ev )
|
|||||||
auto& data = it->second->v;
|
auto& data = it->second->v;
|
||||||
if( !data.empty() && data.back().End() < 0 ) return; // wakeup of a running thread
|
if( !data.empty() && data.back().End() < 0 ) return; // wakeup of a running thread
|
||||||
auto& item = data.push_next();
|
auto& item = data.push_next();
|
||||||
item.wakeup = time;
|
item.SetWakeup( time );
|
||||||
item.SetStart( time );
|
item.SetStart( time );
|
||||||
item.SetEnd( -1 );
|
item.SetEnd( -1 );
|
||||||
item.SetCpu( 0 );
|
item.SetCpu( 0 );
|
||||||
@ -5638,7 +5638,7 @@ void Worker::Write( FileWrite& f )
|
|||||||
int64_t refTime = 0;
|
int64_t refTime = 0;
|
||||||
for( auto& cs : ctx->second->v )
|
for( auto& cs : ctx->second->v )
|
||||||
{
|
{
|
||||||
WriteTimeOffset( f, refTime, cs.wakeup );
|
WriteTimeOffset( f, refTime, cs.WakeupVal() );
|
||||||
WriteTimeOffset( f, refTime, cs.Start() );
|
WriteTimeOffset( f, refTime, cs.Start() );
|
||||||
WriteTimeOffset( f, refTime, cs.End() );
|
WriteTimeOffset( f, refTime, cs.End() );
|
||||||
uint8_t cpu = cs.Cpu();
|
uint8_t cpu = cs.Cpu();
|
||||||
|
Loading…
Reference in New Issue
Block a user