Save/load cached source files.

This commit is contained in:
Bartosz Taudul 2020-05-23 15:43:42 +02:00
parent 5b96809f6f
commit 2f35c785ee
3 changed files with 45 additions and 1 deletions

View File

@ -7,7 +7,7 @@ namespace Version
{
enum { Major = 0 };
enum { Minor = 6 };
enum { Patch = 12 };
enum { Patch = 13 };
}
}

View File

@ -1837,6 +1837,38 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
}
}
if( fileVer >= FileVersion( 0, 6, 13 ) )
{
f.Read( sz );
if( eventMask & EventType::SourceCache )
{
m_data.sourceFileCache.reserve( sz );
for( uint64_t i=0; i<sz; i++ )
{
uint32_t len;
f.Read( len );
auto key = m_slab.Alloc<char>( len+1 );
f.Read( key, len );
key[len] = '\0';
f.Read( len );
auto data = (char*)m_slab.AllocBig( len );
f.Read( data, len );
m_data.sourceFileCache.emplace( key, MemoryBlock { data, len } );
}
}
else
{
for( uint64_t i=0; i<sz; i++ )
{
uint32_t s32;
f.Read( s32 );
f.Skip( s32 );
f.Read( s32 );
f.Skip( s32 );
}
}
}
s_loadProgress.total.store( 0, std::memory_order_relaxed );
m_loadTime = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now() - loadStart ).count();
@ -7195,6 +7227,17 @@ void Worker::Write( FileWrite& f )
f.Write( &diff, sizeof( diff ) );
}
}
sz = m_data.sourceFileCache.size();
f.Write( &sz, sizeof( sz ) );
for( auto& v : m_data.sourceFileCache )
{
uint32_t s32 = strlen( v.first );
f.Write( &s32, sizeof( s32 ) );
f.Write( v.first, s32 );
f.Write( &v.second.len, sizeof( v.second.len ) );
f.Write( v.second.data, v.second.len );
}
}
void Worker::WriteTimeline( FileWrite& f, const Vector<short_ptr<ZoneEvent>>& vec, int64_t& refTime )

View File

@ -44,6 +44,7 @@ namespace EventType
ContextSwitches = 1 << 5,
Samples = 1 << 6,
SymbolCode = 1 << 7,
SourceCache = 1 << 8,
None = 0,
All = std::numeric_limits<uint32_t>::max()