From f143995f27e140155d851636d176d9107cde3288 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 18 Nov 2020 21:45:00 +0100 Subject: [PATCH] clean up memory tracing --- libsrc/core/paje_trace.cpp | 10 +++++----- libsrc/core/profiler.hpp | 14 -------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/libsrc/core/paje_trace.cpp b/libsrc/core/paje_trace.cpp index 1c4843a6..23dcb154 100644 --- a/libsrc/core/paje_trace.cpp +++ b/libsrc/core/paje_trace.cpp @@ -446,14 +446,13 @@ namespace ngcore const int container_jobs = paje.CreateContainer( container_type_jobs, container_task_manager, "Jobs" ); int variable_type_memory = 0; + const int container_memory = paje.CreateContainer( container_type_memory, container_task_manager, "Memory" ); if(mem_tracing_enabled) { variable_type_memory = paje.DefineVariableType( container_type_task_manager, "Memory [MB]" ); - paje.SetVariable( 0, variable_type_memory, container_type_memory, 0.0 ); + paje.SetVariable( 0, variable_type_memory, container_memory, 0.0 ); } - const int container_memory = paje.CreateContainer( container_type_memory, container_task_manager, "Memory" ); - int num_nodes = 1; //task_manager ? task_manager->GetNumNodes() : 1; std::vector thread_aliases; @@ -526,10 +525,11 @@ namespace ngcore for(const auto & m : memory_events) { + double size = 1.0*m.size/(1024*1024); if(m.is_alloc) - paje.AddVariable( m.time, variable_type_memory, container_memory, 1.0*m.size / (1024*1024)); + paje.AddVariable( m.time, variable_type_memory, container_memory, size); else - paje.SubVariable( m.time, variable_type_memory, container_memory, 1.0*m.size / (1024*1024)); + paje.SubVariable( m.time, variable_type_memory, container_memory, size); } std::set timer_ids; diff --git a/libsrc/core/profiler.hpp b/libsrc/core/profiler.hpp index 12233db1..d3b06746 100644 --- a/libsrc/core/profiler.hpp +++ b/libsrc/core/profiler.hpp @@ -316,7 +316,6 @@ namespace ngcore NGCORE_API static std::map< int, std::vector > tree; int id; - std::vector> tracks; public: @@ -345,7 +344,6 @@ namespace ngcore int child_id = GetId(name); tree[id].push_back(child_id); obj.SetMemoryTracing(child_id); - tracks.push_back( [&obj] () { obj.SetMemoryTracing(0); } ); } template @@ -356,22 +354,10 @@ namespace ngcore tree[id].push_back(child_id); } - void StopTracking() - { - for(auto & f : tracks) - f(); - tracks.clear(); - } - static std::string GetName(int id) { return names[id]; } - - ~MemoryTracer() - { - StopTracking(); - } }; NETGEN_INLINE void TraceMemoryAlloc( int mem_id, size_t size )