clean up memory tracing

This commit is contained in:
Matthias Hochsteger 2020-11-18 21:45:00 +01:00
parent 1a93fb3fa5
commit f143995f27
2 changed files with 5 additions and 19 deletions

View File

@ -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 <int> 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<int> timer_ids;

View File

@ -316,7 +316,6 @@ namespace ngcore
NGCORE_API static std::map< int, std::vector<int> > tree;
int id;
std::vector<std::function<void()>> 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<typename T>
@ -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 )