Skip to content

Commit

Permalink
Sampling post-processing Perfetto fix (#298)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrmadsen committed Jul 6, 2023
1 parent 68b4d79 commit 5276c95
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions source/lib/omnitrace/library/sampling.cpp
Expand Up @@ -1144,14 +1144,14 @@ post_process_perfetto(int64_t _tid, const std::vector<timer_sampling_data>& _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<std::string>("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)
Expand Down Expand Up @@ -1233,6 +1233,9 @@ post_process_perfetto(int64_t _tid, const std::vector<timer_sampling_data>& _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) {
Expand Down

0 comments on commit 5276c95

Please sign in to comment.