From 97011ea64215c8ec301e9d065d36a2ed1ce68407 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Thu, 15 Jun 2023 22:37:33 -0500 Subject: [PATCH] Fix thread index values (#287) * Update PTL - PTL submodule waits for threads to start before proceeding * Initialize perfetto after init_bundle - perfetto thread creation after pthread_create wrapped * backtrace component update - exclude gotcha call-tree * callchain component update - callchain::get sorts based on timestamp - callchain::sample supports duplicate IPs (recursion) * Bump version to 1.10.1 [ROCm/rocprofiler-systems commit: de9f0e4c10ff160e253ed1a94c53ca22b865b0de] --- projects/rocprofiler-systems/VERSION | 2 +- projects/rocprofiler-systems/external/PTL | 2 +- .../source/lib/omnitrace/library.cpp | 14 +++++++------- .../lib/omnitrace/library/components/backtrace.cpp | 2 +- .../lib/omnitrace/library/components/callchain.cpp | 11 ++++++++++- .../source/lib/omnitrace/library/ptl.cpp | 6 ++++-- 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/projects/rocprofiler-systems/VERSION b/projects/rocprofiler-systems/VERSION index 81c871de46..4dae2985b5 100644 --- a/projects/rocprofiler-systems/VERSION +++ b/projects/rocprofiler-systems/VERSION @@ -1 +1 @@ -1.10.0 +1.10.1 diff --git a/projects/rocprofiler-systems/external/PTL b/projects/rocprofiler-systems/external/PTL index 37d896f255..f0205c1935 160000 --- a/projects/rocprofiler-systems/external/PTL +++ b/projects/rocprofiler-systems/external/PTL @@ -1 +1 @@ -Subproject commit 37d896f255e39ca8d59913fa26ac39d37eefdf93 +Subproject commit f0205c1935f14861b05152378b7ac1c9234cddc0 diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp index fa4f8c1637..615774b701 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library.cpp @@ -492,13 +492,6 @@ omnitrace_init_tooling_hidden() OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); - // perfetto initialization - if(get_use_perfetto()) - { - OMNITRACE_VERBOSE_F(1, "Setting up Perfetto...\n"); - omnitrace::perfetto::setup(); - } - // ideally these have already been started omnitrace_preinit_hidden(); @@ -507,6 +500,13 @@ omnitrace_init_tooling_hidden() if(get_use_sampling()) sampling::block_signals(); + // perfetto initialization + if(get_use_perfetto()) + { + OMNITRACE_VERBOSE_F(1, "Setting up Perfetto...\n"); + omnitrace::perfetto::setup(); + } + tasking::setup(); if(get_use_causal()) causal::start_experimenting(); diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/backtrace.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/backtrace.cpp index f2ee3c5525..47e3ffb605 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/backtrace.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/backtrace.cpp @@ -120,7 +120,6 @@ backtrace::filter_and_patch(const std::vector& _data) const auto _npos = std::string::npos; if(_keep_internal) return 1; if(_lbl.find("omnitrace_main") != _npos) return 0; - if(_lbl.find("omnitrace::common::") != _npos) return 0; if(_lbl.find("omnitrace::") != _npos) return 0; if(_lbl.find("tim::") != _npos) return 0; if(_lbl.find("DYNINST_") != _npos) return 0; @@ -129,6 +128,7 @@ backtrace::filter_and_patch(const std::vector& _data) if(_lbl.find("roctracer_") != _npos) return -1; if(_lbl.find("perfetto::") != _npos) return -1; if(_lbl.find("protozero::") == 0) return -1; + if(_lbl.find("gotcha_") != _npos) return -1; return 1; }; diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/callchain.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/callchain.cpp index 7ead6b498a..33bbf227ec 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/callchain.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/callchain.cpp @@ -120,6 +120,9 @@ callchain::get() const itr.second.pop_back(); } + std::sort(_v.begin(), _v.end(), + [](const auto& _lhs, const auto& _rhs) { return _lhs.first < _rhs.first; }); + return _v; } @@ -193,9 +196,15 @@ callchain::sample(int signo) auto _data = record{}; _data.timestamp = itr.get_time(); _data.data.emplace_back(_ip); + bool _skip_ip = true; for(auto ditr : itr.get_callchain()) { - if(ditr != _ip) _data.data.emplace_back(ditr); + // skip the first instance of current IP but allow after that since this + // might be a recursive call + if(ditr == _ip && _skip_ip) + _skip_ip = false; + else + _data.data.emplace_back(ditr); if(_data.data.size() == _data.data.capacity()) break; } if(!_data.data.empty()) m_data.emplace_back(_data); diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/ptl.cpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/ptl.cpp index 46a864e190..5ed621336c 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/ptl.cpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/ptl.cpp @@ -96,8 +96,9 @@ get_thread_pool_state() PTL::ThreadPool& get_thread_pool() { - static auto* _v = (get_thread_pool_state() = State::Active, - new PTL::ThreadPool{ _thread_pool_cfg() }); + static auto _cfg = _thread_pool_cfg(); + static auto* _v = + (get_thread_pool_state() = State::Active, new PTL::ThreadPool{ _cfg }); return *_v; } } // namespace @@ -145,6 +146,7 @@ void setup() { OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal); + OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false); (void) get_thread_pool(); }