Skip to content

Commit

Permalink
Merge "Add utid args to async atrace slices" into main am: a1d3cc7
Browse files Browse the repository at this point in the history
Original change: https://android-review.googlesource.com/c/platform/external/perfetto/+/3398599

Change-Id: I8bd6b88157ddc9fdec586cbd4182ec9519af1cc0
Signed-off-by: Automerger Merge Worker <[email protected]>
  • Loading branch information
zezeozue authored and android-build-merge-worker-robot committed Dec 13, 2024
2 parents 9e5cabc + a1d3cc7 commit fd0e365
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/trace_processor/importers/systrace/systrace_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ namespace perfetto::trace_processor {
SystraceParser::SystraceParser(TraceProcessorContext* ctx)
: context_(ctx),
lmk_id_(ctx->storage->InternString("mem.lmk")),
cookie_id_(ctx->storage->InternString("cookie")) {}
cookie_id_(ctx->storage->InternString("cookie")),
utid_id_(ctx->storage->InternString("utid")),
end_utid_id_(ctx->storage->InternString("end_utid")) {}

SystraceParser::~SystraceParser() = default;

Expand Down Expand Up @@ -250,16 +252,33 @@ void SystraceParser::ParseSystracePoint(
if (point.phase == 'N') {
TrackId track_id =
context_->async_track_set_tracker->Scoped(track_set_id, ts, 0);
context_->slice_tracker->Scoped(ts, track_id, kNullStringId, name_id,
0);
auto utid = context_->process_tracker->GetOrCreateThread(pid);
context_->slice_tracker->Scoped(
ts, track_id, kNullStringId, name_id, 0,
[this, utid](ArgsTracker::BoundInserter* inserter) {
inserter->AddArg(utid_id_, Variadic::UnsignedInteger(utid),
ArgsTracker::UpdatePolicy::kSkipIfExists);
});
} else if (point.phase == 'G') {
TrackId track_id = context_->async_track_set_tracker->Begin(
track_set_id, point.int_value);
context_->slice_tracker->Begin(ts, track_id, kNullStringId, name_id);
auto utid = context_->process_tracker->GetOrCreateThread(pid);
context_->slice_tracker->Begin(
ts, track_id, kNullStringId, name_id,
[this, utid](ArgsTracker::BoundInserter* inserter) {
inserter->AddArg(utid_id_, Variadic::UnsignedInteger(utid),
ArgsTracker::UpdatePolicy::kSkipIfExists);
});
} else if (point.phase == 'H') {
TrackId track_id = context_->async_track_set_tracker->End(
track_set_id, point.int_value);
context_->slice_tracker->End(ts, track_id);
auto utid = context_->process_tracker->GetOrCreateThread(pid);
context_->slice_tracker->End(
ts, track_id, {}, {},
[this, utid](ArgsTracker::BoundInserter* inserter) {
inserter->AddArg(end_utid_id_, Variadic::UnsignedInteger(utid),
ArgsTracker::UpdatePolicy::kSkipIfExists);
});
}
break;
}
Expand Down Expand Up @@ -315,8 +334,7 @@ void SystraceParser::ParseSystracePoint(
ts, static_cast<double>(point.int_value), track_id,
[this, opt_utid](ArgsTracker::BoundInserter* inserter) {
if (opt_utid) {
inserter->AddArg(context_->storage->InternString("utid"),
Variadic::UnsignedInteger(*opt_utid),
inserter->AddArg(utid_id_, Variadic::UnsignedInteger(*opt_utid),
ArgsTracker::UpdatePolicy::kSkipIfExists);
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/trace_processor/importers/systrace/systrace_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ class SystraceParser : public Destructible {
TraceProcessorContext* const context_;
const StringId lmk_id_;
const StringId cookie_id_;
const StringId utid_id_;
const StringId end_utid_id_;
};

} // namespace trace_processor
Expand Down
13 changes: 13 additions & 0 deletions test/trace_processor/diff_tests/tables/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,16 @@ def test_cpu_track_table_machine_id(self):
4096,0,1
4097,1,1
"""))

def test_async_slice_utid_arg_set_id(self):
return DiffTestBlueprint(
trace=DataPath('android_monitor_contention_trace.atr'),
query="""
SELECT COUNT(DISTINCT extract_arg(arg_set_id, 'utid')) AS utid_count,
COUNT(DISTINCT extract_arg(arg_set_id, 'end_utid')) AS end_utid_count
FROM counter
""",
out=Csv("""
"utid_count","end_utid_count"
89,0
"""))

0 comments on commit fd0e365

Please sign in to comment.