Skip to content

Commit

Permalink
tp: migrate existing uses of InternTrack to new track interning
Browse files Browse the repository at this point in the history
Change-Id: I63abcb949dfc9ba338fff14fe096d251c459626f
  • Loading branch information
LalitMaganti committed Dec 2, 2024
1 parent d7af572 commit 72cc5eb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
#include "src/trace_processor/importers/common/event_tracker.h"
#include "src/trace_processor/importers/common/slice_tracker.h"
#include "src/trace_processor/importers/common/track_tracker.h"
#include "src/trace_processor/importers/common/tracks_internal.h"
#include "src/trace_processor/importers/common/tracks.h"
#include "src/trace_processor/importers/common/tracks_common.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/slice_tables_py.h"

Expand All @@ -39,12 +40,12 @@ void GpuWorkPeriodTracker::ParseGpuWorkPeriodEvent(int64_t timestamp,
protozero::ConstBytes blob) {
protos::pbzero::GpuWorkPeriodFtraceEvent::Decoder evt(blob);

TrackTracker::DimensionsBuilder dims_builder =
context_->track_tracker->CreateDimensionsBuilder();
dims_builder.AppendGpu(evt.gpu_id());
dims_builder.AppendUid(static_cast<int32_t>(evt.uid()));
static constexpr auto kTrackBlueprint = tracks::SliceBlueprint(
"android_gpu_work_period",
tracks::DimensionBlueprints(tracks::kGpuDimensionBlueprint,
tracks::kUidDimensionBlueprint));
TrackId track_id = context_->track_tracker->InternTrack(
tracks::android_gpu_work_period, std::move(dims_builder).Build());
kTrackBlueprint, {evt.gpu_id(), static_cast<int32_t>(evt.uid())});

const auto duration =
static_cast<int64_t>(evt.end_time_ns() - evt.start_time_ns());
Expand Down
35 changes: 26 additions & 9 deletions src/trace_processor/importers/proto/metadata_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@

#include "src/trace_processor/importers/proto/metadata_module.h"

#include <cstdint>
#include <string>

#include "perfetto/ext/base/base64.h"
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/string_view.h"
#include "perfetto/ext/base/uuid.h"
#include "perfetto/trace_processor/ref_counted.h"
#include "src/trace_processor/importers/common/flow_tracker.h"
#include "src/trace_processor/importers/common/metadata_tracker.h"
#include "src/trace_processor/importers/common/parser_types.h"
#include "src/trace_processor/importers/common/slice_tracker.h"
#include "src/trace_processor/importers/common/track_tracker.h"
#include "src/trace_processor/importers/common/tracks.h"
#include "src/trace_processor/importers/proto/config.descriptor.h"
#include "src/trace_processor/importers/proto/packet_sequence_state_generation.h"
#include "src/trace_processor/importers/proto/proto_importer_module.h"
#include "src/trace_processor/storage/metadata.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/types/variadic.h"
#include "src/trace_processor/util/descriptors.h"
#include "src/trace_processor/util/protozero_to_text.h"

Expand All @@ -34,11 +44,19 @@
#include "protos/perfetto/trace/trace_uuid.pbzero.h"
#include "protos/perfetto/trace/trigger.pbzero.h"

namespace perfetto {
namespace trace_processor {
namespace perfetto::trace_processor {

namespace {

using perfetto::protos::pbzero::TracePacket;

constexpr auto kTriggerTrackBlueprint =
tracks::SliceBlueprint("triggers",
tracks::DimensionBlueprints(),
tracks::StaticNameBlueprint("Trace Triggers"));

} // namespace

MetadataModule::MetadataModule(TraceProcessorContext* context)
: context_(context),
producer_name_key_id_(context_->storage->InternString("producer_name")),
Expand Down Expand Up @@ -109,8 +127,8 @@ void MetadataModule::ParseTracePacketData(
void MetadataModule::ParseTrigger(int64_t ts, ConstBytes blob) {
protos::pbzero::Trigger::Decoder trigger(blob.data, blob.size);
StringId cat_id = kNullStringId;
TrackId track_id = context_->track_tracker->InternGlobalTrack(
tracks::triggers, TrackTracker::LegacyCharArrayName("Trace Triggers"));
TrackId track_id =
context_->track_tracker->InternTrack(kTriggerTrackBlueprint);
StringId name_id = context_->storage->InternString(trigger.trigger_name());
context_->slice_tracker->Scoped(
ts, track_id, cat_id, name_id,
Expand All @@ -130,10 +148,10 @@ void MetadataModule::ParseTrigger(int64_t ts, ConstBytes blob) {
}

void MetadataModule::ParseChromeTrigger(int64_t ts, ConstBytes blob) {
protos::pbzero::ChromeTrigger::Decoder trigger(blob.data, blob.size);
protos::pbzero::ChromeTrigger::Decoder trigger(blob);
StringId cat_id = kNullStringId;
TrackId track_id =
context_->track_tracker->InternGlobalTrack(tracks::triggers);
context_->track_tracker->InternTrack(kTriggerTrackBlueprint);
StringId name_id;
if (trigger.has_trigger_name()) {
name_id = context_->storage->InternString(trigger.trigger_name());
Expand Down Expand Up @@ -215,5 +233,4 @@ void MetadataModule::ParseTraceConfig(
Variadic::String(id));
}

} // namespace trace_processor
} // namespace perfetto
} // namespace perfetto::trace_processor

0 comments on commit 72cc5eb

Please sign in to comment.