From 3a186887ed469058e5a01808b4b42f6a17c2219c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 2 Jun 2024 15:52:37 +0200 Subject: [PATCH] Added compression streams to save trace UI. --- profiler/src/profiler/TracyView.cpp | 18 +++++++++++++----- profiler/src/profiler/TracyView.hpp | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index 7a7a7dcf..67d61aac 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -551,8 +551,8 @@ bool View::Draw() ImGui::PopFont(); ImGui::Separator(); - static FileCompression comp = FileCompression::Fast; - static int zlvl = 6; + static FileCompression comp = FileCompression::Zstd; + static int zlvl = 3; ImGui::TextUnformatted( ICON_FA_FILE_ZIPPER " Trace compression" ); ImGui::SameLine(); TextDisabledUnformatted( "Can be changed later with the upgrade utility" ); @@ -576,6 +576,14 @@ bool View::Draw() } ImGui::Unindent(); + static int streams = 4; + ImGui::TextUnformatted( ICON_FA_SHUFFLE " Compression streams" ); + ImGui::SameLine(); + TextDisabledUnformatted( "Parallelize save and load at the cost of file size" ); + ImGui::Indent(); + ImGui::SliderInt( "##streams", &streams, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp ); + ImGui::Unindent(); + static bool buildDict = false; if( m_worker.GetFrameImageCount() != 0 ) { @@ -588,7 +596,7 @@ bool View::Draw() ImGui::Separator(); if( ImGui::Button( ICON_FA_FLOPPY_DISK " Save trace" ) ) { - saveFailed = !Save( fn, comp, zlvl, buildDict ); + saveFailed = !Save( fn, comp, zlvl, buildDict, streams ); m_filenameStaging.clear(); ImGui::CloseCurrentPopup(); } @@ -1340,9 +1348,9 @@ void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before ImGui::PopStyleVar(); } -bool View::Save( const char* fn, FileCompression comp, int zlevel, bool buildDict ) +bool View::Save( const char* fn, FileCompression comp, int zlevel, bool buildDict, int streams ) { - std::unique_ptr f( FileWrite::Open( fn, comp, zlevel ) ); + std::unique_ptr f( FileWrite::Open( fn, comp, zlevel, streams ) ); if( !f ) return false; m_userData.StateShouldBePreserved(); diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 55289f27..e2e48373 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -367,7 +367,7 @@ private: void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map& data, int64_t& ztime ); void SetPlaybackFrame( uint32_t idx ); - bool Save( const char* fn, FileCompression comp, int zlevel, bool buildDict ); + bool Save( const char* fn, FileCompression comp, int zlevel, bool buildDict, int streams ); void Attention( bool& alreadyDone ); void UpdateTitle();