Add interface for frame images dict building.

This commit is contained in:
Bartosz Taudul 2021-05-15 15:50:20 +02:00
parent 859b8e4193
commit 3d75bf653a
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
7 changed files with 22 additions and 11 deletions

View File

@ -248,7 +248,7 @@ int main( int argc, char** argv )
auto f = std::unique_ptr<tracy::FileWrite>( tracy::FileWrite::Open( output ) );
if( f )
{
worker.Write( *f );
worker.Write( *f, false );
printf( " \033[32;1mdone!\033[0m\n" );
f->Finish();
const auto stats = f->GetCompressionStatistics();

View File

@ -350,7 +350,7 @@ int main( int argc, char** argv )
}
printf( "\33[2KSaving...\r" );
fflush( stdout );
worker.Write( *w );
worker.Write( *w, false );
printf( "\33[2KCleanup...\n" );
fflush( stdout );

View File

@ -657,10 +657,16 @@ bool View::Draw()
ImGui::SliderInt( "##zstd", &zlvl, 1, 22, "%d", ImGuiSliderFlags_AlwaysClamp );
ImGui::Unindent();
ImGui::Separator();
static bool buildDict = false;
ImGui::Checkbox( "Build frame images dictionary", &buildDict );
ImGui::SameLine();
TextDisabledUnformatted( "Decreases run-time memory requirements" );
ImGui::Separator();
if( ImGui::Button( ICON_FA_SAVE " Save trace" ) )
{
saveFailed = !s_instance->Save( fn, comp, zlvl );
saveFailed = !s_instance->Save( fn, comp, zlvl, buildDict );
s_instance->m_filenameStaging.clear();
ImGui::CloseCurrentPopup();
}
@ -18036,16 +18042,16 @@ void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before
if( separateTooltip ) ImGui::EndTooltip();
}
bool View::Save( const char* fn, FileWrite::Compression comp, int zlevel )
bool View::Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict )
{
std::unique_ptr<FileWrite> f( FileWrite::Open( fn, comp, zlevel ) );
if( !f ) return false;
m_userData.StateShouldBePreserved();
m_saveThreadState.store( SaveThreadState::Saving, std::memory_order_relaxed );
m_saveThread = std::thread( [this, f{std::move( f )}] {
m_saveThread = std::thread( [this, f{std::move( f )}, buildDict] {
std::lock_guard<std::mutex> lock( m_worker.GetDataLock() );
m_worker.Write( *f );
m_worker.Write( *f, buildDict );
f->Finish();
const auto stats = f->GetCompressionStatistics();
m_srcFileBytes.store( stats.first, std::memory_order_relaxed );

View File

@ -283,7 +283,7 @@ private:
void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, int64_t& ztime, const ZoneEvent& zone );
void SetPlaybackFrame( uint32_t idx );
bool Save( const char* fn, FileWrite::Compression comp, int zlevel );
bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict );
unordered_flat_map<const void*, VisData> m_visData;
unordered_flat_map<uint64_t, bool> m_visibleMsgThread;

View File

@ -6898,7 +6898,7 @@ void Worker::Disconnect()
m_disconnect = true;
}
void Worker::Write( FileWrite& f )
void Worker::Write( FileWrite& f, bool fiDict )
{
DoPostponedWork();

View File

@ -579,7 +579,7 @@ public:
void Disconnect();
bool WasDisconnectIssued() const { return m_disconnect; }
void Write( FileWrite& f );
void Write( FileWrite& f, bool fiDict );
int GetTraceVersion() const { return m_traceVersion; }
uint8_t GetHandshakeStatus() const { return m_handshake.load( std::memory_order_relaxed ); }
int64_t GetSamplingPeriod() const { return m_samplingPeriod; }

View File

@ -29,6 +29,7 @@ void Usage()
printf( " -h: enable LZ4HC compression\n" );
printf( " -e: enable extreme LZ4HC compression (very slow)\n" );
printf( " -z level: use Zstd compression with given compression level\n" );
printf( " -d: build dictionary for frame images\n" );
printf( " -s flags: strip selected data from capture:\n" );
printf( " l: locks, m: messages, p: plots, M: memory, i: frame images\n" );
printf( " c: context switches, s: sampling data, C: symbol code, S: source cache\n" );
@ -48,8 +49,9 @@ int main( int argc, char** argv )
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
uint32_t events = tracy::EventType::All;
int zstdLevel = 1;
bool buildDict = false;
int c;
while( ( c = getopt( argc, argv, "hez:s:" ) ) != -1 )
while( ( c = getopt( argc, argv, "hez:ds:" ) ) != -1 )
{
switch( c )
{
@ -68,6 +70,9 @@ int main( int argc, char** argv )
exit( 1 );
}
break;
case 'd':
buildDict = true;
break;
case 's':
{
auto ptr = optarg;
@ -150,7 +155,7 @@ int main( int argc, char** argv )
}
printf( "Saving... \r" );
fflush( stdout );
worker.Write( *w );
worker.Write( *w, buildDict );
w->Finish();
const auto t1 = std::chrono::high_resolution_clock::now();
const auto stats = w->GetCompressionStatistics();