From e135d3c6ebf9cef2b37dec564bd3884cf857576a Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Thu, 6 Jul 2023 02:40:49 -0500 Subject: [PATCH] Sampling post-processing Perfetto fix (#298) sampling post-processing perfetto fix - avoid creating overflow sampling perfetto tracks when there is no data - fix the parent region begin/end timestamps for the sampling tracks [ROCm/rocprofiler-systems commit: 5276c957fb9f06a8f3dee70c16b3cd3ee4eedf1f] --- .../source/lib/omnitrace/library/sampling.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/sampling.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/sampling.cpp index 7996d55a87..69434049ca 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/sampling.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/sampling.cpp @@ -1144,14 +1144,14 @@ post_process_perfetto(int64_t _tid, const std::vector& _tim if(!_thread_info) return; - uint64_t _beg_ns = _thread_info->get_start(); - uint64_t _end_ns = _thread_info->get_stop(); - auto _overflow_event = get_setting_value("OMNITRACE_SAMPLING_OVERFLOW_EVENT").value_or(""); - if(!_overflow_event.empty()) + if(!_overflow_event.empty() && !_overflow_data.empty()) { + auto _beg_ns = std::max(_overflow_data.front().m_beg, _thread_info->get_start()); + auto _end_ns = std::min(_overflow_data.back().m_end, _thread_info->get_stop()); + const auto _overflow_prefix = std::string_view{ "PERF_COUNT_" }; const auto _overflow_pos = _overflow_event.find(_overflow_prefix); if(_overflow_pos != std::string::npos) @@ -1233,6 +1233,9 @@ post_process_perfetto(int64_t _tid, const std::vector& _tim if(!_timer_data.empty()) { + auto _beg_ns = std::max(_timer_data.front().m_beg, _thread_info->get_start()); + auto _end_ns = std::min(_timer_data.back().m_end, _thread_info->get_stop()); + auto _track = tracing::get_perfetto_track( category::timer_sampling{}, [](auto _seq_id, auto _sys_id) {