From fa53c2e683e6883737b407e96b059e3d8690c941 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 10 Nov 2019 19:20:57 +0100 Subject: [PATCH] Don't care about memory usage tracking data races. --- capture/src/capture.cpp | 4 ++-- server/TracyMemory.cpp | 2 +- server/TracyMemory.hpp | 3 +-- server/TracySlab.hpp | 10 +++++----- server/TracyVector.hpp | 12 ++++++------ server/TracyView.cpp | 4 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/capture/src/capture.cpp b/capture/src/capture.cpp index db0e0537..27c926b2 100644 --- a/capture/src/capture.cpp +++ b/capture/src/capture.cpp @@ -129,11 +129,11 @@ int main( int argc, char** argv ) { printf( "\33[2K\r\033[36;1m%7.2f Mbps", mbps ); } - printf( " \033[0m /\033[36;1m%5.1f%% \033[0m=\033[33;1m%7.2f Mbps \033[0m| \033[33mNet: \033[32m%s \033[0m| \033[33mMem: \033[31;1m%.2f MB\033[0m | \033[33mTime: %s\033[0m", + printf( " \033[0m /\033[36;1m%5.1f%% \033[0m=\033[33;1m%7.2f Mbps \033[0m| \033[33mNet: \033[32m%s \033[0m| \033[33mMem: \033[31;1m%s\033[0m | \033[33mTime: %s\033[0m", compRatio * 100.f, mbps / compRatio, tracy::MemSizeToString( netTotal ), - tracy::memUsage.load( std::memory_order_relaxed ) / ( 1024.f * 1024.f ), + tracy::MemSizeToString( tracy::memUsage ), tracy::TimeToString( worker.GetLastTime() ) ); fflush( stdout ); diff --git a/server/TracyMemory.cpp b/server/TracyMemory.cpp index ccc6eec7..4899a87c 100644 --- a/server/TracyMemory.cpp +++ b/server/TracyMemory.cpp @@ -3,6 +3,6 @@ namespace tracy { -std::atomic memUsage( 0 ); +size_t memUsage = 0; } diff --git a/server/TracyMemory.hpp b/server/TracyMemory.hpp index 183999a6..50015472 100644 --- a/server/TracyMemory.hpp +++ b/server/TracyMemory.hpp @@ -1,13 +1,12 @@ #ifndef __TRACYMEMORY_HPP__ #define __TRACYMEMORY_HPP__ -#include #include namespace tracy { -extern std::atomic memUsage; +extern size_t memUsage; } diff --git a/server/TracySlab.hpp b/server/TracySlab.hpp index 118a60d5..b7f4aba6 100644 --- a/server/TracySlab.hpp +++ b/server/TracySlab.hpp @@ -19,12 +19,12 @@ public: , m_buffer( { m_ptr } ) , m_usage( BlockSize ) { - memUsage.fetch_add( BlockSize, std::memory_order_relaxed ); + memUsage += BlockSize; } ~Slab() { - memUsage.fetch_sub( m_usage, std::memory_order_relaxed ); + memUsage -= m_usage; for( auto& v : m_buffer ) { delete[] v; @@ -113,7 +113,7 @@ public: } else { - memUsage.fetch_add( size, std::memory_order_relaxed ); + memUsage += size; m_usage += size; auto ret = new char[size]; m_buffer.emplace_back( ret ); @@ -125,7 +125,7 @@ public: { if( m_buffer.size() > 1 ) { - memUsage.fetch_sub( m_usage - BlockSize, std::memory_order_relaxed ); + memUsage -= m_usage - BlockSize; m_usage = BlockSize; for( int i=1; i ) ); @@ -239,7 +239,7 @@ public: cap |= cap >> 8; cap |= cap >> 16; cap = TracyCountBits( cap ); - memUsage.fetch_add( ( ( 1 << cap ) - Capacity() ) * sizeof( T ), std::memory_order_relaxed ); + memUsage += ( ( 1 << cap ) - Capacity() ) * sizeof( T ); m_capacity = cap; Realloc(); } @@ -276,13 +276,13 @@ private: if( m_ptr == nullptr ) { - memUsage.fetch_add( sizeof( T ), std::memory_order_relaxed ); + memUsage += sizeof( T ); m_ptr = new T[1]; m_capacity = 0; } else { - memUsage.fetch_add( Capacity() * sizeof( T ), std::memory_order_relaxed ); + memUsage += Capacity() * sizeof( T ); m_capacity++; Realloc(); } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 2385187e..4534b884 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -953,7 +953,7 @@ bool View::DrawConnection() TextFocused( "Query backlog:", RealToString( m_worker.GetSendQueueSize(), true ) ); } - TextFocused( "Memory usage:", MemSizeToString( memUsage.load( std::memory_order_relaxed ) ) ); + TextFocused( "Memory usage:", MemSizeToString( memUsage ) ); const auto wpos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin(); ImGui::GetWindowDrawList()->AddCircleFilled( wpos + ImVec2( 1 + cs * 0.5, 3 + ty * 1.75 ), cs * 0.5, m_worker.IsConnected() ? 0xFF2222CC : 0xFF444444, 10 ); @@ -10761,7 +10761,7 @@ void View::DrawInfo() if( ImGui::TreeNode( "Profiler statistics" ) ) { - TextFocused( "Profiler memory usage:", MemSizeToString( memUsage.load( std::memory_order_relaxed ) ) ); + TextFocused( "Profiler memory usage:", MemSizeToString( memUsage ) ); TextFocused( "Profiler FPS:", RealToString( int( io.Framerate ), true ) ); ImGui::TreePop(); }