diff --git a/libsrc/core/paje_trace.cpp b/libsrc/core/paje_trace.cpp index 00fd1758..818a92c8 100644 --- a/libsrc/core/paje_trace.cpp +++ b/libsrc/core/paje_trace.cpp @@ -670,9 +670,21 @@ namespace ngcore std::map containers; + for(auto i : Range(user_containers.size())) + { + auto & [name, parent] = user_containers[i]; + int a_parent = parent == -1 ? container_task_manager : containers[parent]; + containers[i] = paje.CreateContainer( container_type_timer, a_parent, name ); + } + for(auto ev : user_events) + { if(containers[ev.container]==0) - containers[ev.container] = paje.CreateContainer( container_type_timer, container_task_manager, "User " + ToString(ev.container) ); + { + std::string name = "User " + ToString(ev.container); + containers[ev.container] = paje.CreateContainer( container_type_timer, container_task_manager, name ); + } + } int i_start = 0; for(auto i : Range(user_events.size())) diff --git a/libsrc/core/paje_trace.hpp b/libsrc/core/paje_trace.hpp index b7a3de50..7adc6c58 100644 --- a/libsrc/core/paje_trace.hpp +++ b/libsrc/core/paje_trace.hpp @@ -1,6 +1,7 @@ #ifndef NETGEN_CORE_PAJE_TRACE_HPP #define NETGEN_CORE_PAJE_TRACE_HPP +#include #include #include @@ -99,8 +100,8 @@ namespace ngcore struct UserEvent { - TTimePoint t_start, t_end; - std::string data; + TTimePoint t_start = 0, t_end = 0; + std::string data = ""; int container = 0; int id = 0; @@ -130,6 +131,7 @@ namespace ngcore std::vector jobs; std::vector timer_events; std::vector user_events; + std::vector> user_containers; std::vector gpu_events; std::vector > links; NGCORE_API static std::vector memory_events; @@ -146,10 +148,19 @@ namespace ngcore void operator=(const PajeTrace &) = delete; void operator=(PajeTrace &&) = delete; - void AddUserEvent(TTimePoint t_start, TTimePoint t_end, const std::string & data, int container = 0, int id=0 ) + int AddUserContainer(std::string name, int parent=-1) + { + if(auto pos = std::find(user_containers.begin(), user_containers.end(), std::tuple{name,parent}); pos != user_containers.end()) + return pos - user_containers.begin(); + int id = user_containers.size(); + user_containers.push_back({name, parent}); + return id; + } + + void AddUserEvent(UserEvent ue) { if(!tracing_enabled) return; - user_events.push_back(UserEvent{t_start, t_end, data, container, id}); + user_events.push_back(ue); } void StartGPU(int timer_id = 0) {