Save one byte on ContextSwitchData.

This commit is contained in:
Bartosz Taudul 2019-08-13 13:19:38 +02:00
parent d77c87ae1c
commit f285e0f5cc
2 changed files with 10 additions and 8 deletions

View File

@ -222,11 +222,13 @@ enum { CrashEventSize = sizeof( CrashEvent ) };
struct ContextSwitchData
{
static uint8_t Reason( const ContextSwitchData& cs ) { return cs.data & 0xF; }
static uint8_t State( const ContextSwitchData& cs ) { return cs.data >> 4; }
int64_t start;
int64_t end;
uint8_t cpu;
int8_t reason;
int8_t state;
uint8_t data;
};
enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) };

View File

@ -1168,7 +1168,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
{
ptr->start = ReadTimeOffset( f, refTime );
ptr->end = ReadTimeOffset( f, refTime );
f.Read( &ptr->cpu, sizeof( ptr->cpu ) + sizeof( ptr->reason ) + sizeof( ptr->state ) );
f.Read( &ptr->cpu, sizeof( ptr->cpu ) + sizeof( ptr->data ) );
ptr++;
}
m_data.ctxSwitch.emplace( thread, data );
@ -3727,8 +3727,9 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
auto& item = data.back();
assert( item.start <= time );
item.end = time;
item.reason = ev.reason;
item.state = ev.state;
assert( ( ev.reason & 0xF ) == ev.reason );
assert( ( ev.state & 0xF ) == ev.state );
item.data = ev.reason | ( ev.state << 4 );
}
}
if( ev.newThread != 0 )
@ -3745,8 +3746,7 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
item.start = time;
item.end = -1;
item.cpu = ev.cpu;
item.reason = -1;
item.state = -1;
item.data = ~0;
}
}
@ -4497,7 +4497,7 @@ void Worker::Write( FileWrite& f )
{
WriteTimeOffset( f, refTime, cs.start );
WriteTimeOffset( f, refTime, cs.end );
f.Write( &cs.cpu, sizeof( cs.cpu ) + sizeof( cs.reason ) + sizeof( cs.state ) );
f.Write( &cs.cpu, sizeof( cs.cpu ) + sizeof( cs.data ) );
}
}
}