mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Parallelize (big) sorts in worker.
This commit is contained in:
parent
dbc963d55c
commit
920bfc8c82
@ -5,6 +5,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <execution>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "../common/TracyProtocol.hpp"
|
#include "../common/TracyProtocol.hpp"
|
||||||
@ -14,7 +15,6 @@
|
|||||||
#include "TracyWorker.hpp"
|
#include "TracyWorker.hpp"
|
||||||
|
|
||||||
#include "tracy_flat_hash_map.hpp"
|
#include "tracy_flat_hash_map.hpp"
|
||||||
#include "tracy_pdqsort.h"
|
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
for( auto& v : m_data.sourceLocationZones )
|
for( auto& v : m_data.sourceLocationZones )
|
||||||
{
|
{
|
||||||
auto& zones = v.second.zones;
|
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::sort( std::execution::par_unseq, zones.begin(), zones.end(), []( const auto& lhs, const auto& rhs ) { return lhs.zone->start < rhs.zone->start; } );
|
||||||
}
|
}
|
||||||
std::lock_guard lock( m_data.lock );
|
std::lock_guard lock( m_data.lock );
|
||||||
m_data.sourceLocationZonesReady = true;
|
m_data.sourceLocationZonesReady = true;
|
||||||
@ -1296,7 +1296,7 @@ void Worker::HandlePostponedPlots()
|
|||||||
if( src.empty() ) continue;
|
if( src.empty() ) continue;
|
||||||
if( std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count() - plot->postponeTime < 100 ) continue;
|
if( std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count() - plot->postponeTime < 100 ) continue;
|
||||||
auto& dst = plot->data;
|
auto& dst = plot->data;
|
||||||
pdqsort_branchless( src.begin(), src.end(), [] ( const auto& l, const auto& r ) { return l.time < r.time; } );
|
std::sort( std::execution::par_unseq, src.begin(), src.end(), [] ( const auto& l, const auto& r ) { return l.time < r.time; } );
|
||||||
const auto ds = std::lower_bound( dst.begin(), dst.end(), src.front().time, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
const auto ds = std::lower_bound( dst.begin(), dst.end(), src.front().time, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
||||||
const auto dsd = std::distance( dst.begin(), ds ) ;
|
const auto dsd = std::distance( dst.begin(), ds ) ;
|
||||||
const auto de = std::lower_bound( ds, dst.end(), src.back().time, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
const auto de = std::lower_bound( ds, dst.end(), src.back().time, [] ( const auto& l, const auto& r ) { return l.time < r; } );
|
||||||
@ -1919,7 +1919,7 @@ void Worker::CreateMemAllocPlot()
|
|||||||
void Worker::ReconstructMemAllocPlot()
|
void Worker::ReconstructMemAllocPlot()
|
||||||
{
|
{
|
||||||
auto& mem = m_data.memory;
|
auto& mem = m_data.memory;
|
||||||
pdqsort_branchless( mem.frees.begin(), mem.frees.end(), [&mem] ( const auto& lhs, const auto& rhs ) { return mem.data[lhs].timeFree < mem.data[rhs].timeFree; } );
|
std::sort( std::execution::par_unseq, mem.frees.begin(), mem.frees.end(), [&mem] ( const auto& lhs, const auto& rhs ) { return mem.data[lhs].timeFree < mem.data[rhs].timeFree; } );
|
||||||
|
|
||||||
const auto psz = mem.data.size() + mem.frees.size() + 1;
|
const auto psz = mem.data.size() + mem.frees.size() + 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user