mirror of
https://github.com/wolfpld/tracy
synced 2025-05-06 07:03:52 +00:00
Sort source location zones on a separate thread.
This commit is contained in:
parent
63e4f6fa04
commit
76f0c8fafe
@ -3085,6 +3085,13 @@ void View::DrawFindZone()
|
|||||||
ImGui::TextWrapped( "Collection of statistical data is disabled in this build." );
|
ImGui::TextWrapped( "Collection of statistical data is disabled in this build." );
|
||||||
ImGui::TextWrapped( "Rebuild without the TRACY_NO_STATISTICS macro to enable zone search." );
|
ImGui::TextWrapped( "Rebuild without the TRACY_NO_STATISTICS macro to enable zone search." );
|
||||||
#else
|
#else
|
||||||
|
if( !m_worker.AreSourceLocationZonesReady() )
|
||||||
|
{
|
||||||
|
ImGui::TextWrapped( "Please wait, computing data..." );
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::InputText( "", m_findZone.pattern, 1024 );
|
ImGui::InputText( "", m_findZone.pattern, 1024 );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
@ -3849,6 +3856,13 @@ void View::DrawCompare()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !m_worker.AreSourceLocationZonesReady() || !m_compare.second->AreSourceLocationZonesReady() )
|
||||||
|
{
|
||||||
|
ImGui::TextWrapped( "Please wait, computing data..." );
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TextDisabled( "This trace:" );
|
ImGui::TextDisabled( "This trace:" );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text( "%s", m_worker.GetCaptureName().c_str() );
|
ImGui::Text( "%s", m_worker.GetCaptureName().c_str() );
|
||||||
@ -4371,6 +4385,13 @@ void View::DrawStatistics()
|
|||||||
ImGui::TextWrapped( "Collection of statistical data is disabled in this build." );
|
ImGui::TextWrapped( "Collection of statistical data is disabled in this build." );
|
||||||
ImGui::TextWrapped( "Rebuild without the TRACY_NO_STATISTICS macro to enable statistics view." );
|
ImGui::TextWrapped( "Rebuild without the TRACY_NO_STATISTICS macro to enable statistics view." );
|
||||||
#else
|
#else
|
||||||
|
if( !m_worker.AreSourceLocationZonesReady() )
|
||||||
|
{
|
||||||
|
ImGui::TextWrapped( "Please wait, computing data..." );
|
||||||
|
ImGui::End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto& slz = m_worker.GetSourceLocationZones();
|
auto& slz = m_worker.GetSourceLocationZones();
|
||||||
Vector<decltype(slz.begin())> srcloc;
|
Vector<decltype(slz.begin())> srcloc;
|
||||||
srcloc.reserve( slz.size() );
|
srcloc.reserve( slz.size() );
|
||||||
|
@ -184,6 +184,10 @@ Worker::Worker( const char* addr )
|
|||||||
{
|
{
|
||||||
m_data.sourceLocationExpand.push_back( 0 );
|
m_data.sourceLocationExpand.push_back( 0 );
|
||||||
|
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
m_data.sourceLocationZonesReady = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_thread = std::thread( [this] { Exec(); } );
|
m_thread = std::thread( [this] { Exec(); } );
|
||||||
SetThreadName( m_thread, "Tracy Worker" );
|
SetThreadName( m_thread, "Tracy Worker" );
|
||||||
}
|
}
|
||||||
@ -293,6 +297,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
m_data.sourceLocationZonesReady = false;
|
||||||
m_data.sourceLocationZones.reserve( sle + sz );
|
m_data.sourceLocationZones.reserve( sle + sz );
|
||||||
for( uint64_t i=1; i<sle; i++ )
|
for( uint64_t i=1; i<sle; i++ )
|
||||||
{
|
{
|
||||||
@ -450,11 +455,15 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
for( auto& v : m_data.sourceLocationZones )
|
m_threadZones = std::thread( [this] {
|
||||||
{
|
for( auto& v : m_data.sourceLocationZones )
|
||||||
auto& zones = v.second.zones;
|
{
|
||||||
pdqsort_branchless( zones.begin(), zones.end(), []( const auto& lhs, const auto& rhs ) { return lhs.zone->start < rhs.zone->start; } );
|
auto& zones = v.second.zones;
|
||||||
}
|
pdqsort_branchless( zones.begin(), zones.end(), []( const auto& lhs, const auto& rhs ) { return lhs.zone->start < rhs.zone->start; } );
|
||||||
|
}
|
||||||
|
std::lock_guard<NonRecursiveBenaphore> lock( m_data.lock );
|
||||||
|
m_data.sourceLocationZonesReady = true;
|
||||||
|
} );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
f.Read( &sz, sizeof( sz ) );
|
f.Read( &sz, sizeof( sz ) );
|
||||||
@ -532,7 +541,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
f.Read( &m_data.memory.low, sizeof( m_data.memory.low ) );
|
f.Read( &m_data.memory.low, sizeof( m_data.memory.low ) );
|
||||||
f.Read( &m_data.memory.usage, sizeof( m_data.memory.usage ) );
|
f.Read( &m_data.memory.usage, sizeof( m_data.memory.usage ) );
|
||||||
|
|
||||||
m_loadThread = std::thread( [this] { ReconstructMemAllocPlot(); } );
|
m_threadMemory = std::thread( [this] { ReconstructMemAllocPlot(); } );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -562,7 +571,8 @@ Worker::~Worker()
|
|||||||
Shutdown();
|
Shutdown();
|
||||||
|
|
||||||
if( m_thread.joinable() ) m_thread.join();
|
if( m_thread.joinable() ) m_thread.join();
|
||||||
if( m_loadThread.joinable() ) m_loadThread.join();
|
if( m_threadMemory.joinable() ) m_threadMemory.join();
|
||||||
|
if( m_threadZones.joinable() ) m_threadZones.join();
|
||||||
|
|
||||||
delete[] m_buffer;
|
delete[] m_buffer;
|
||||||
LZ4_freeStreamDecode( m_stream );
|
LZ4_freeStreamDecode( m_stream );
|
||||||
|
@ -93,6 +93,7 @@ class Worker
|
|||||||
Vector<uint64_t> sourceLocationExpand;
|
Vector<uint64_t> sourceLocationExpand;
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
flat_hash_map<int32_t, SourceLocationZones, nohash<int32_t>> sourceLocationZones;
|
flat_hash_map<int32_t, SourceLocationZones, nohash<int32_t>> sourceLocationZones;
|
||||||
|
bool sourceLocationZonesReady;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<uint32_t, LockMap> lockMap;
|
std::map<uint32_t, LockMap> lockMap;
|
||||||
@ -157,6 +158,7 @@ public:
|
|||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
const SourceLocationZones& GetZonesForSourceLocation( int32_t srcloc ) const;
|
const SourceLocationZones& GetZonesForSourceLocation( int32_t srcloc ) const;
|
||||||
const flat_hash_map<int32_t, SourceLocationZones, nohash<int32_t>>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
|
const flat_hash_map<int32_t, SourceLocationZones, nohash<int32_t>>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
|
||||||
|
bool AreSourceLocationZonesReady() const { return m_data.sourceLocationZonesReady; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tracy_force_inline uint16_t CompressThread( uint64_t thread );
|
tracy_force_inline uint16_t CompressThread( uint64_t thread );
|
||||||
@ -254,11 +256,13 @@ private:
|
|||||||
Socket m_sock;
|
Socket m_sock;
|
||||||
std::string m_addr;
|
std::string m_addr;
|
||||||
|
|
||||||
std::thread m_thread, m_loadThread;
|
std::thread m_thread;
|
||||||
std::atomic<bool> m_connected;
|
std::atomic<bool> m_connected;
|
||||||
std::atomic<bool> m_hasData;
|
std::atomic<bool> m_hasData;
|
||||||
std::atomic<bool> m_shutdown;
|
std::atomic<bool> m_shutdown;
|
||||||
|
|
||||||
|
std::thread m_threadMemory, m_threadZones;
|
||||||
|
|
||||||
int64_t m_delay;
|
int64_t m_delay;
|
||||||
int64_t m_resolution;
|
int64_t m_resolution;
|
||||||
double m_timerMul;
|
double m_timerMul;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user