diff --git a/capture/src/capture.cpp b/capture/src/capture.cpp index f42279a6..4736550e 100644 --- a/capture/src/capture.cpp +++ b/capture/src/capture.cpp @@ -248,7 +248,7 @@ int main( int argc, char** argv ) auto f = std::unique_ptr( 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(); diff --git a/import-chrome/src/import-chrome.cpp b/import-chrome/src/import-chrome.cpp index 8a5df664..6127b6d9 100644 --- a/import-chrome/src/import-chrome.cpp +++ b/import-chrome/src/import-chrome.cpp @@ -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 ); diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 520cae1b..7df2d5f0 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -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 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 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 ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 99e3d427..7e7ddfa3 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -283,7 +283,7 @@ private: void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map& 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 m_visData; unordered_flat_map m_visibleMsgThread; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index e85fc694..1881dc4b 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -6898,7 +6898,7 @@ void Worker::Disconnect() m_disconnect = true; } -void Worker::Write( FileWrite& f ) +void Worker::Write( FileWrite& f, bool fiDict ) { DoPostponedWork(); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 5e8f21f0..e2c1c16a 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -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; } diff --git a/update/src/update.cpp b/update/src/update.cpp index bfe65e31..bd923a3f 100644 --- a/update/src/update.cpp +++ b/update/src/update.cpp @@ -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();