Skip to content

Commit

Permalink
Fix thread index values (#287)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jrmadsen authored Jun 16, 2023
1 parent 262f1e9 commit de9f0e4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.0
1.10.1
2 changes: 1 addition & 1 deletion external/PTL
14 changes: 7 additions & 7 deletions source/lib/omnitrace/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion source/lib/omnitrace/library/components/backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ backtrace::filter_and_patch(const std::vector<entry_type>& _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;
Expand All @@ -129,6 +128,7 @@ backtrace::filter_and_patch(const std::vector<entry_type>& _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;
};

Expand Down
11 changes: 10 additions & 1 deletion source/lib/omnitrace/library/components/callchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions source/lib/omnitrace/library/ptl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -145,6 +146,7 @@ void
setup()
{
OMNITRACE_SCOPED_THREAD_STATE(ThreadState::Internal);
OMNITRACE_SCOPED_SAMPLING_ON_CHILD_THREADS(false);
(void) get_thread_pool();
}

Expand Down

0 comments on commit de9f0e4

Please sign in to comment.