From 109ab3ebcb7f48423af346cb375f9495e0a3d998 Mon Sep 17 00:00:00 2001 From: Lalit Maganti Date: Mon, 21 Oct 2024 06:44:25 -0700 Subject: [PATCH] tp: simplify track classification Switch to a macro based approach similar to how metadata and stats work. This reduces the boilerplate of keeping the enum in sync with the classification string exposed to SQL: both are the same now. Change-Id: I859183b8123e3d1a2c6bbb0ba08f4bf758e55a0a --- BUILD | 2 +- src/trace_processor/export_json_unittest.cc | 16 +- src/trace_processor/importers/common/BUILD.gn | 2 +- .../common/async_track_set_tracker.cc | 4 +- .../common/event_tracker_unittest.cc | 4 +- .../importers/common/track_classification.h | 186 -------------- .../importers/common/track_tracker.cc | 227 +++++++++--------- .../importers/common/track_tracker.h | 36 +-- src/trace_processor/importers/common/tracks.h | 87 +++++++ .../importers/ftrace/ftrace_parser.cc | 48 ++-- .../ftrace/gpu_work_period_tracker.cc | 5 +- .../ftrace/mali_gpu_event_tracker.cc | 2 +- .../importers/ftrace/pkvm_hyp_cpu_tracker.cc | 10 +- .../importers/json/json_trace_parser_impl.cc | 5 +- .../importers/proto/android_probes_parser.cc | 8 +- .../proto/memory_tracker_snapshot_parser.cc | 2 +- .../importers/proto/metadata_module.cc | 5 +- .../importers/proto/system_probes_parser.cc | 24 +- .../importers/proto/track_event_parser.cc | 5 +- .../importers/proto/track_event_tracker.cc | 25 +- .../systrace/systrace_line_parser.cc | 4 +- .../importers/systrace/systrace_parser.cc | 6 +- .../plugins/dev.perfetto.AsyncSlices/index.ts | 4 +- ui/src/plugins/dev.perfetto.Counter/index.ts | 4 - 24 files changed, 307 insertions(+), 414 deletions(-) delete mode 100644 src/trace_processor/importers/common/track_classification.h create mode 100644 src/trace_processor/importers/common/tracks.h diff --git a/BUILD b/BUILD index 49ec7c5dab..5e736f5703 100644 --- a/BUILD +++ b/BUILD @@ -1628,9 +1628,9 @@ perfetto_filegroup( "src/trace_processor/importers/common/trace_file_tracker.cc", "src/trace_processor/importers/common/trace_file_tracker.h", "src/trace_processor/importers/common/trace_parser.cc", - "src/trace_processor/importers/common/track_classification.h", "src/trace_processor/importers/common/track_tracker.cc", "src/trace_processor/importers/common/track_tracker.h", + "src/trace_processor/importers/common/tracks.h", "src/trace_processor/importers/common/virtual_memory_mapping.cc", "src/trace_processor/importers/common/virtual_memory_mapping.h", ], diff --git a/src/trace_processor/export_json_unittest.cc b/src/trace_processor/export_json_unittest.cc index 818c360831..08c4148365 100644 --- a/src/trace_processor/export_json_unittest.cc +++ b/src/trace_processor/export_json_unittest.cc @@ -43,8 +43,8 @@ #include "src/trace_processor/importers/common/metadata_tracker.h" #include "src/trace_processor/importers/common/process_track_translation_table.h" #include "src/trace_processor/importers/common/process_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/importers/proto/track_event_tracker.h" #include "src/trace_processor/storage/metadata.h" #include "src/trace_processor/storage/stats.h" @@ -252,8 +252,8 @@ TEST_F(ExportJsonTest, StorageWithThreadName) { } TEST_F(ExportJsonTest, SystemEventsIgnored) { - TrackId track = context_.track_tracker->InternProcessTrack( - TrackClassification::kUnknown, 0); + TrackId track = + context_.track_tracker->InternProcessTrack(tracks::unknown, 0); context_.args_tracker->Flush(); // Flush track args. // System events have no category. @@ -770,7 +770,7 @@ TEST_F(ExportJsonTest, InstantEvent) { // Global legacy track. TrackId track = context_.track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant, TrackTracker::AutoName(), + tracks::legacy_chrome_global_instants, TrackTracker::AutoName(), [this](ArgsTracker::BoundInserter& inserter) { inserter.AddArg( context_.storage->InternString("source"), @@ -1814,8 +1814,8 @@ TEST_F(ExportJsonTest, MemorySnapshotOsDumpEvent) { const char* kModuleDebugPath = "debugpath"; UniquePid upid = context_.process_tracker->GetOrCreateProcess(kProcessID); - TrackId track = context_.track_tracker->InternProcessTrack( - TrackClassification::kTrackEvent, upid); + TrackId track = + context_.track_tracker->InternProcessTrack(tracks::track_event, upid); StringId level_of_detail_id = context_.storage->InternString(base::StringView(kLevelOfDetail)); auto snapshot_id = context_.storage->mutable_memory_snapshot_table() @@ -1936,8 +1936,8 @@ TEST_F(ExportJsonTest, MemorySnapshotChromeDumpEvent) { UniquePid os_upid = context_.process_tracker->GetOrCreateProcess(kOsProcessID); - TrackId track = context_.track_tracker->InternProcessTrack( - TrackClassification::kTrackEvent, os_upid); + TrackId track = + context_.track_tracker->InternProcessTrack(tracks::track_event, os_upid); StringId level_of_detail_id = context_.storage->InternString(base::StringView(kLevelOfDetail)); auto snapshot_id = context_.storage->mutable_memory_snapshot_table() diff --git a/src/trace_processor/importers/common/BUILD.gn b/src/trace_processor/importers/common/BUILD.gn index 27d1ccaf84..8be9508e75 100644 --- a/src/trace_processor/importers/common/BUILD.gn +++ b/src/trace_processor/importers/common/BUILD.gn @@ -69,9 +69,9 @@ source_set("common") { "trace_file_tracker.cc", "trace_file_tracker.h", "trace_parser.cc", - "track_classification.h", "track_tracker.cc", "track_tracker.h", + "tracks.h", "virtual_memory_mapping.cc", "virtual_memory_mapping.h", ] diff --git a/src/trace_processor/importers/common/async_track_set_tracker.cc b/src/trace_processor/importers/common/async_track_set_tracker.cc index 513d092c2c..dab0af0e08 100644 --- a/src/trace_processor/importers/common/async_track_set_tracker.cc +++ b/src/trace_processor/importers/common/async_track_set_tracker.cc @@ -187,7 +187,7 @@ TrackId AsyncTrackSetTracker::CreateTrackForSet(const TrackSet& set) { context_->track_tracker->CreateDimensionsBuilder(); builder.AppendName(set.global_track_name); return context_->track_tracker->CreateTrack( - TrackClassification::kUnknown, std::move(builder).Build(), + tracks::unknown, std::move(builder).Build(), TrackTracker::LegacyStringIdName{set.global_track_name}); } case TrackSetScope::kProcess: @@ -208,7 +208,7 @@ TrackId AsyncTrackSetTracker::CreateTrackForSet(const TrackSet& set) { TrackTracker::Dimensions dims_id = std::move(dims_builder).Build(); TrackId id = context_->track_tracker->CreateProcessTrack( - TrackClassification::kUnknown, set.process_tuple.upid, dims_id, + tracks::unknown, set.process_tuple.upid, dims_id, TrackTracker::LegacyStringIdName{name}); if (!source.is_null()) { diff --git a/src/trace_processor/importers/common/event_tracker_unittest.cc b/src/trace_processor/importers/common/event_tracker_unittest.cc index 171c2c9eee..3f99c7881b 100644 --- a/src/trace_processor/importers/common/event_tracker_unittest.cc +++ b/src/trace_processor/importers/common/event_tracker_unittest.cc @@ -54,8 +54,8 @@ TEST_F(EventTrackerTest, CounterDuration) { uint32_t cpu = 3; int64_t timestamp = 100; - TrackId track = context.track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, cpu); + TrackId track = + context.track_tracker->InternCpuCounterTrack(tracks::cpu_frequency, cpu); context.event_tracker->PushCounter(timestamp, 1000, track); context.event_tracker->PushCounter(timestamp + 1, 4000, track); context.event_tracker->PushCounter(timestamp + 3, 5000, track); diff --git a/src/trace_processor/importers/common/track_classification.h b/src/trace_processor/importers/common/track_classification.h deleted file mode 100644 index 82818f6a69..0000000000 --- a/src/trace_processor/importers/common/track_classification.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_TRACK_CLASSIFICATION_H_ -#define SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_TRACK_CLASSIFICATION_H_ - -#include -#include "perfetto/base/logging.h" - -namespace perfetto::trace_processor { - -// The classification of a track indicates the "type of data" the track -// contains. -// -// Every track is uniquely identified by the the combination of the -// classification and a set of dimensions: classifications allow identifying a -// set of tracks with the same type of data within the whole universe of tracks -// while dimensions allow distinguishing between different tracks in that set. -enum class TrackClassification : size_t { - // Global tracks, unique per trace. - kTrigger, - kInterconnect, - kChromeLegacyGlobalInstant, - - // General tracks. - kThread, - kChromeProcessInstant, - kTrackEvent, - - // Gpu tracks. - kGpuFrequency, - - // Cpu tracks. - kIrqCpu, - kSoftirqCpu, - kNapiGroCpu, - kMaliIrqCpu, - kFuncgraphCpu, - kPkvmHypervisor, - - // Cpu counter tracks. - kCpuFrequency, - kCpuFrequencyThrottle, - kCpuMaxFrequencyLimit, - kCpuMinFrequencyLimit, - - kCpuIdle, - kCpuIdleState, - kCpuUtilization, - kCpuCapacity, - kCpuNumberRunning, - - // Time CPU spent in state. - kUserTime, - kNiceUserTime, - kSystemModeTime, - kIoWaitTime, - kIrqTime, - kSoftIrqTime, - kCpuIdleTime, - - // Android begin. - // Energy estimation. - kAndroidEnergyEstimationBreakdown, - kAndroidEnergyEstimationBreakdownPerUid, - // GPU Work period from Android kernels. - kAndroidGpuWorkPeriod, - // Per-process LMK track. - kAndroidLmk, - // Android end. - - // Linux begin. - kIrqCounter, - kSoftirqCounter, - kLinuxRuntimePowerManagement, - kLinuxDeviceFrequency, - // Linux end. - - // Not set. Legacy, never use for new tracks. - // If set the classification can't be used to decide the tracks and - // dimensions + name should be used instead. Strongly discouraged. - kUnknown, - - // Keep last and equal to max value. - kMax = kUnknown, -}; - -static inline const char* TrackClassificationToString( - TrackClassification type) { - switch (type) { - case TrackClassification::kTrigger: - return "triggers"; - case TrackClassification::kInterconnect: - return "interconnect_events"; - case TrackClassification::kChromeLegacyGlobalInstant: - return "legacy_chrome_global_instants"; - case TrackClassification::kThread: - return "thread"; - case TrackClassification::kChromeProcessInstant: - return "chrome_process_instant"; - case TrackClassification::kLinuxRuntimePowerManagement: - return "linux_rpm"; - case TrackClassification::kLinuxDeviceFrequency: - return "linux_device_frequency"; - case TrackClassification::kTrackEvent: - return "track_event"; - case TrackClassification::kIrqCounter: - return "irq_counter"; - case TrackClassification::kSoftirqCounter: - return "softirq_counter"; - case TrackClassification::kGpuFrequency: - return "gpu_frequency"; - case TrackClassification::kFuncgraphCpu: - return "cpu_funcgraph"; - case TrackClassification::kIrqCpu: - return "cpu_irq"; - case TrackClassification::kIrqTime: - return "cpu_irq_time"; - case TrackClassification::kMaliIrqCpu: - return "cpu_mali_irq"; - case TrackClassification::kNapiGroCpu: - return "cpu_napi_gro"; - case TrackClassification::kSoftirqCpu: - return "cpu_softirq"; - case TrackClassification::kSoftIrqTime: - return "cpu_softirq_time"; - case TrackClassification::kPkvmHypervisor: - return "pkvm_hypervisor"; - case TrackClassification::kCpuFrequency: - return "cpu_frequency"; - case TrackClassification::kCpuFrequencyThrottle: - return "cpu_frequency_throttle"; - case TrackClassification::kCpuMinFrequencyLimit: - return "cpu_min_frequency_limit"; - case TrackClassification::kCpuMaxFrequencyLimit: - return "cpu_max_frequency_limit"; - case TrackClassification::kCpuCapacity: - return "cpu_capacity"; - case TrackClassification::kCpuIdle: - return "cpu_idle"; - case TrackClassification::kCpuIdleTime: - return "cpu_idle_time"; - case TrackClassification::kCpuIdleState: - return "cpu_idle_state"; - case TrackClassification::kIoWaitTime: - return "cpu_io_wait_time"; - case TrackClassification::kCpuNumberRunning: - return "cpu_nr_running"; - case TrackClassification::kCpuUtilization: - return "cpu_utilization"; - case TrackClassification::kSystemModeTime: - return "cpu_system_mode_time"; - case TrackClassification::kUserTime: - return "cpu_user_time"; - case TrackClassification::kNiceUserTime: - return "cpu_nice_user_time"; - case TrackClassification::kAndroidEnergyEstimationBreakdown: - return "android_energy_estimation_breakdown"; - case TrackClassification::kAndroidEnergyEstimationBreakdownPerUid: - return "android_energy_estimation_breakdown_per_uid"; - case TrackClassification::kAndroidGpuWorkPeriod: - return "android_gpu_work_period"; - case TrackClassification::kAndroidLmk: - return "android_lmk"; - case TrackClassification::kUnknown: - return "N/A"; - } - PERFETTO_FATAL("For GCC"); -} - -} // namespace perfetto::trace_processor - -#endif // SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_TRACK_CLASSIFICATION_H_ diff --git a/src/trace_processor/importers/common/track_tracker.cc b/src/trace_processor/importers/common/track_tracker.cc index 253fc14d0c..e510ef72c1 100644 --- a/src/trace_processor/importers/common/track_tracker.cc +++ b/src/trace_processor/importers/common/track_tracker.cc @@ -24,12 +24,11 @@ #include "perfetto/base/compiler.h" #include "perfetto/base/logging.h" -#include "perfetto/ext/base/string_utils.h" #include "perfetto/ext/base/string_view.h" #include "src/trace_processor/importers/common/args_tracker.h" #include "src/trace_processor/importers/common/cpu_tracker.h" #include "src/trace_processor/importers/common/process_track_translation_table.h" -#include "src/trace_processor/importers/common/track_classification.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/tables/profiler_tables_py.h" #include "src/trace_processor/tables/track_tables_py.h" @@ -65,42 +64,41 @@ const char* GetNameForGroup(TrackTracker::Group group) { PERFETTO_FATAL("For GCC"); } -bool IsLegacyStringIdNameAllowed(TrackClassification classification) { +bool IsLegacyStringIdNameAllowed(tracks::TrackClassification classification) { // **DO NOT** add new values here. Use TrackTracker::AutoName instead. - return classification == - TrackClassification::kAndroidEnergyEstimationBreakdown || + return classification == tracks::android_energy_estimation_breakdown || classification == - TrackClassification::kAndroidEnergyEstimationBreakdownPerUid || - classification == TrackClassification::kUnknown; + tracks::android_energy_estimation_breakdown_per_uid || + classification == tracks::unknown; } -bool IsLegacyCharArrayNameAllowed(TrackClassification classification) { +bool IsLegacyCharArrayNameAllowed(tracks::TrackClassification classification) { // **DO NOT** add new values here. Use TrackTracker::AutoName instead. - return classification == TrackClassification::kTrigger || - classification == TrackClassification::kInterconnect || - classification == TrackClassification::kLinuxRuntimePowerManagement || - classification == TrackClassification::kIrqCpu || - classification == TrackClassification::kSoftirqCpu || - classification == TrackClassification::kNapiGroCpu || - classification == TrackClassification::kFuncgraphCpu || - classification == TrackClassification::kMaliIrqCpu || - classification == TrackClassification::kPkvmHypervisor || - classification == TrackClassification::kCpuFrequency || - classification == TrackClassification::kCpuFrequencyThrottle || - classification == TrackClassification::kCpuIdle || - classification == TrackClassification::kUserTime || - classification == TrackClassification::kSystemModeTime || - classification == TrackClassification::kCpuIdleTime || - classification == TrackClassification::kIoWaitTime || - classification == TrackClassification::kIrqTime || - classification == TrackClassification::kSoftIrqTime || - classification == TrackClassification::kIrqCounter || - classification == TrackClassification::kSoftirqCounter || - classification == TrackClassification::kCpuUtilization || - classification == TrackClassification::kCpuCapacity || - classification == TrackClassification::kCpuNumberRunning || - classification == TrackClassification::kCpuMaxFrequencyLimit || - classification == TrackClassification::kCpuMinFrequencyLimit; + return classification == tracks::triggers || + classification == tracks::interconnect_events || + classification == tracks::linux_rpm || + classification == tracks::cpu_irq || + classification == tracks::cpu_softirq || + classification == tracks::cpu_napi_gro || + classification == tracks::cpu_funcgraph || + classification == tracks::cpu_mali_irq || + classification == tracks::pkvm_hypervisor || + classification == tracks::cpu_frequency || + classification == tracks::cpu_frequency_throttle || + classification == tracks::cpu_idle || + classification == tracks::cpu_user_time || + classification == tracks::cpu_system_mode_time || + classification == tracks::cpu_idleTime || + classification == tracks::cpu_io_wait_time || + classification == tracks::cpu_irq_time || + classification == tracks::cpu_softirq_time || + classification == tracks::irq_counter || + classification == tracks::softirq_counter || + classification == tracks::cpu_utilization || + classification == tracks::cpu_capacity || + classification == tracks::cpu_nr_running || + classification == tracks::cpu_max_frequency_limit || + classification == tracks::cpu_min_frequency_limit; } } // namespace @@ -124,12 +122,12 @@ TrackTracker::TrackTracker(TraceProcessorContext* context) name_id_(context->storage->InternString("name")), context_(context) {} -TrackId TrackTracker::CreateTrack(TrackClassification classification, +TrackId TrackTracker::CreateTrack(tracks::TrackClassification classification, std::optional dimensions, const TrackName& name) { tables::TrackTable::Row row(StringIdFromTrackName(classification, name)); - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); if (dimensions) { row.dimension_arg_set_id = dimensions->arg_set_id; } @@ -138,13 +136,14 @@ TrackId TrackTracker::CreateTrack(TrackClassification classification, return context_->storage->mutable_track_table()->Insert(row).id; } -TrackId TrackTracker::CreateCounterTrack(TrackClassification classification, - std::optional dimensions, - const TrackName& name) { +TrackId TrackTracker::CreateCounterTrack( + tracks::TrackClassification classification, + std::optional dimensions, + const TrackName& name) { tables::CounterTrackTable::Row row( StringIdFromTrackName(classification, name)); - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); if (dimensions) { row.dimension_arg_set_id = dimensions->arg_set_id; } @@ -153,10 +152,11 @@ TrackId TrackTracker::CreateCounterTrack(TrackClassification classification, return context_->storage->mutable_counter_track_table()->Insert(row).id; } -TrackId TrackTracker::CreateProcessTrack(TrackClassification classification, - UniquePid upid, - std::optional dims, - const TrackName& name) { +TrackId TrackTracker::CreateProcessTrack( + tracks::TrackClassification classification, + UniquePid upid, + std::optional dims, + const TrackName& name) { Dimensions dims_id = dims ? *dims : SingleDimension(upid_id_, Variadic::Integer(upid)); @@ -164,15 +164,15 @@ TrackId TrackTracker::CreateProcessTrack(TrackClassification classification, StringIdFromTrackName(classification, name)); row.upid = upid; row.dimension_arg_set_id = dims_id.arg_set_id; - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); row.machine_id = context_->machine_id(); return context_->storage->mutable_process_track_table()->Insert(row).id; } TrackId TrackTracker::CreateProcessCounterTrack( - TrackClassification classification, + tracks::TrackClassification classification, UniquePid upid, std::optional dims, const TrackName& name) { @@ -184,24 +184,25 @@ TrackId TrackTracker::CreateProcessCounterTrack( row.upid = upid; row.machine_id = context_->machine_id(); row.dimension_arg_set_id = dims_id.arg_set_id; - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); return context_->storage->mutable_process_counter_track_table() ->Insert(row) .id; } -TrackId TrackTracker::CreateThreadTrack(TrackClassification classification, - UniqueTid utid, - const TrackName& name) { +TrackId TrackTracker::CreateThreadTrack( + tracks::TrackClassification classification, + UniqueTid utid, + const TrackName& name) { Dimensions dims_id = SingleDimension(utid_id_, Variadic::Integer(utid)); tables::ThreadTrackTable::Row row( StringIdFromTrackName(classification, name)); row.utid = utid; - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); row.dimension_arg_set_id = dims_id.arg_set_id; row.machine_id = context_->machine_id(); @@ -209,7 +210,7 @@ TrackId TrackTracker::CreateThreadTrack(TrackClassification classification, } TrackId TrackTracker::CreateThreadCounterTrack( - TrackClassification classification, + tracks::TrackClassification classification, UniqueTid utid, const TrackName& name) { Dimensions dims_id = SingleDimension(utid_id_, Variadic::Integer(utid)); @@ -219,15 +220,15 @@ TrackId TrackTracker::CreateThreadCounterTrack( row.utid = utid; row.machine_id = context_->machine_id(); row.dimension_arg_set_id = dims_id.arg_set_id; - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); return context_->storage->mutable_thread_counter_track_table() ->Insert(row) .id; } -TrackId TrackTracker::InternTrack(TrackClassification classification, +TrackId TrackTracker::InternTrack(tracks::TrackClassification classification, std::optional dimensions, const TrackName& name, const SetArgsCallback& callback) { @@ -244,9 +245,10 @@ TrackId TrackTracker::InternTrack(TrackClassification classification, return id; } -TrackId TrackTracker::InternCounterTrack(TrackClassification classification, - std::optional dimensions, - const TrackName& name) { +TrackId TrackTracker::InternCounterTrack( + tracks::TrackClassification classification, + std::optional dimensions, + const TrackName& name) { auto* it = tracks_.Find({classification, dimensions}); if (it) return *it; @@ -256,9 +258,10 @@ TrackId TrackTracker::InternCounterTrack(TrackClassification classification, return id; } -TrackId TrackTracker::InternProcessTrack(TrackClassification classification, - UniquePid upid, - const TrackName& name) { +TrackId TrackTracker::InternProcessTrack( + tracks::TrackClassification classification, + UniquePid upid, + const TrackName& name) { Dimensions dims_id = SingleDimension(upid_id_, Variadic::Integer(upid)); auto* it = tracks_.Find({classification, dims_id}); @@ -279,7 +282,7 @@ TrackId TrackTracker::LegacyInternProcessCounterTrack(StringId raw_name, context_->process_track_translation_table->TranslateName(raw_name); TrackMapKey key; - key.classification = TrackClassification::kUnknown; + key.classification = tracks::unknown; DimensionsBuilder dims_builder = CreateDimensionsBuilder(); dims_builder.AppendUpid(upid); @@ -296,8 +299,8 @@ TrackId TrackTracker::LegacyInternProcessCounterTrack(StringId raw_name, row.unit = unit; row.description = description; row.machine_id = context_->machine_id(); - row.classification = context_->storage->InternString( - TrackClassificationToString(key.classification)); + row.classification = + context_->storage->InternString(tracks::ToString(key.classification)); row.dimension_arg_set_id = key.dimensions->arg_set_id; TrackId track_id = context_->storage->mutable_process_counter_track_table()->Insert(row).id; @@ -309,19 +312,18 @@ TrackId TrackTracker::LegacyInternProcessCounterTrack(StringId raw_name, TrackId TrackTracker::InternThreadTrack(UniqueTid utid, const TrackName& name) { Dimensions dims = SingleDimension(utid_id_, Variadic::Integer(utid)); - auto* it = tracks_.Find({TrackClassification::kThread, dims}); + auto* it = tracks_.Find({tracks::thread, dims}); if (it) return *it; - TrackId track_id = - CreateThreadTrack(TrackClassification::kThread, utid, name); - tracks_[{TrackClassification::kThread, dims}] = track_id; + TrackId track_id = CreateThreadTrack(tracks::thread, utid, name); + tracks_[{tracks::thread, dims}] = track_id; return track_id; } TrackId TrackTracker::LegacyInternThreadCounterTrack(StringId name, UniqueTid utid) { TrackMapKey key; - key.classification = TrackClassification::kUnknown; + key.classification = tracks::unknown; DimensionsBuilder dims_builder = CreateDimensionsBuilder(); dims_builder.AppendUtid(utid); @@ -333,13 +335,13 @@ TrackId TrackTracker::LegacyInternThreadCounterTrack(StringId name, return *it; } - TrackId track_id = CreateThreadCounterTrack(TrackClassification::kUnknown, - utid, LegacyStringIdName{name}); + TrackId track_id = + CreateThreadCounterTrack(tracks::unknown, utid, LegacyStringIdName{name}); tracks_[key] = track_id; return track_id; } -TrackId TrackTracker::InternCpuTrack(TrackClassification classification, +TrackId TrackTracker::InternCpuTrack(tracks::TrackClassification classification, uint32_t cpu, const TrackName& name) { auto ucpu = context_->cpu_tracker->GetOrCreateCpu(cpu); @@ -353,8 +355,8 @@ TrackId TrackTracker::InternCpuTrack(TrackClassification classification, tables::CpuTrackTable::Row row(StringIdFromTrackName(classification, name)); row.ucpu = ucpu; row.machine_id = context_->machine_id(); - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); row.dimension_arg_set_id = dims_id.arg_set_id; TrackId track_id = @@ -363,9 +365,10 @@ TrackId TrackTracker::InternCpuTrack(TrackClassification classification, return track_id; } -TrackId TrackTracker::InternGlobalTrack(TrackClassification classification, - const TrackName& name, - const SetArgsCallback& callback) { +TrackId TrackTracker::InternGlobalTrack( + tracks::TrackClassification classification, + const TrackName& name, + const SetArgsCallback& callback) { return InternTrack(classification, std::nullopt, name, callback); } @@ -380,7 +383,7 @@ TrackId TrackTracker::LegacyInternGpuTrack( Dimensions dims_id = std::move(dims_builder).Build(); TrackMapKey key; - key.classification = TrackClassification::kUnknown; + key.classification = tracks::unknown; key.dimensions = dims_id; auto* it = tracks_.Find(key); @@ -388,8 +391,8 @@ TrackId TrackTracker::LegacyInternGpuTrack( return *it; auto row_copy = row; - row_copy.classification = context_->storage->InternString( - TrackClassificationToString(TrackClassification::kUnknown)); + row_copy.classification = + context_->storage->InternString(tracks::ToString(tracks::unknown)); row_copy.dimension_arg_set_id = dims_id.arg_set_id; row_copy.machine_id = context_->machine_id(); @@ -405,7 +408,7 @@ TrackId TrackTracker::LegacyInternGlobalCounterTrack(TrackTracker::Group group, StringId unit, StringId description) { TrackMapKey key; - key.classification = TrackClassification::kUnknown; + key.classification = tracks::unknown; key.dimensions = SingleDimension(name_id_, Variadic::String(name)); auto* it = tracks_.Find(key); @@ -418,8 +421,8 @@ TrackId TrackTracker::LegacyInternGlobalCounterTrack(TrackTracker::Group group, row.unit = unit; row.description = description; row.machine_id = context_->machine_id(); - row.classification = context_->storage->InternString( - TrackClassificationToString(TrackClassification::kUnknown)); + row.classification = + context_->storage->InternString(tracks::ToString(tracks::unknown)); TrackId track = context_->storage->mutable_counter_track_table()->Insert(row).id; @@ -433,9 +436,10 @@ TrackId TrackTracker::LegacyInternGlobalCounterTrack(TrackTracker::Group group, return track; } -TrackId TrackTracker::InternCpuCounterTrack(TrackClassification classification, - uint32_t cpu, - const TrackName& name) { +TrackId TrackTracker::InternCpuCounterTrack( + tracks::TrackClassification classification, + uint32_t cpu, + const TrackName& name) { auto ucpu = context_->cpu_tracker->GetOrCreateCpu(cpu); StringId name_id = StringIdFromTrackName(classification, name); @@ -455,8 +459,8 @@ TrackId TrackTracker::InternCpuCounterTrack(TrackClassification classification, tables::CpuCounterTrackTable::Row row(name_id); row.ucpu = ucpu; row.machine_id = context_->machine_id(); - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); row.dimension_arg_set_id = key.dimensions->arg_set_id; TrackId track_id = @@ -475,7 +479,7 @@ TrackId TrackTracker::LegacyInternCpuIdleStateTrack(uint32_t cpu, dims_builder.AppendUcpu(ucpu); Dimensions dims_id = std::move(dims_builder).Build(); - TrackClassification classification = TrackClassification::kCpuIdleState; + tracks::TrackClassification classification = tracks::cpu_idle_state; auto* it = tracks_.Find({classification, dims_id}); if (it) { @@ -489,8 +493,8 @@ TrackId TrackTracker::LegacyInternCpuIdleStateTrack(uint32_t cpu, context_->storage->InternString(name.c_str())); row.ucpu = ucpu; row.machine_id = context_->machine_id(); - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); + row.classification = + context_->storage->InternString(tracks::ToString(classification)); row.dimension_arg_set_id = dims_id.arg_set_id; TrackId track_id = @@ -499,9 +503,10 @@ TrackId TrackTracker::LegacyInternCpuIdleStateTrack(uint32_t cpu, return track_id; } -TrackId TrackTracker::InternGpuCounterTrack(TrackClassification classification, - uint32_t gpu_id, - const TrackName& name) { +TrackId TrackTracker::InternGpuCounterTrack( + tracks::TrackClassification classification, + uint32_t gpu_id, + const TrackName& name) { Dimensions dims_id = SingleDimension(gpu_id_, Variadic::Integer(gpu_id)); auto* it = tracks_.Find({classification, dims_id}); @@ -514,9 +519,9 @@ TrackId TrackTracker::InternGpuCounterTrack(TrackClassification classification, row.gpu_id = gpu_id; row.machine_id = context_->machine_id(); row.dimension_arg_set_id = dims_id.arg_set_id; - row.classification = context_->storage->InternString( - TrackClassificationToString(classification)); - if (classification == TrackClassification::kGpuFrequency) + row.classification = + context_->storage->InternString(tracks::ToString(classification)); + if (classification == tracks::gpu_frequency) row.name = context_->storage->InternString("gpufreq"); TrackId track_id = @@ -535,8 +540,8 @@ TrackId TrackTracker::LegacyCreateGpuCounterTrack(StringId name, row.description = description; row.unit = unit; row.machine_id = context_->machine_id(); - row.classification = context_->storage->InternString( - TrackClassificationToString(TrackClassification::kUnknown)); + row.classification = + context_->storage->InternString(tracks::ToString(tracks::unknown)); row.dimension_arg_set_id = SingleDimension(gpu_id_, Variadic::Integer(gpu_id)).arg_set_id; @@ -561,8 +566,8 @@ TrackId TrackTracker::LegacyCreatePerfCounterTrack( row.cpu = cpu; row.is_timebase = is_timebase; row.dimension_arg_set_id = dims_id.arg_set_id; - row.classification = context_->storage->InternString( - TrackClassificationToString(TrackClassification::kUnknown)); + row.classification = + context_->storage->InternString(tracks::ToString(tracks::unknown)); row.machine_id = context_->machine_id(); return context_->storage->mutable_perf_counter_track_table()->Insert(row).id; } @@ -575,8 +580,8 @@ TrackId TrackTracker::InternTrackForGroup(TrackTracker::Group group) { } StringId name_id = context_->storage->InternString(GetNameForGroup(group)); - TrackId track_id = InternTrack(TrackClassification::kUnknown, std::nullopt, - LegacyStringIdName{name_id}); + TrackId track_id = + InternTrack(tracks::unknown, std::nullopt, LegacyStringIdName{name_id}); group_track_ids_[group_idx] = track_id; return track_id; } @@ -598,7 +603,7 @@ TrackId TrackTracker::LegacyInternLegacyChromeAsyncTrack( context_->process_track_translation_table->TranslateName(raw_name); TrackMapKey key; - key.classification = TrackClassification::kUnknown; + key.classification = tracks::unknown; key.dimensions = std::move(dims_builder).Build(); auto* it = tracks_.Find(key); @@ -619,8 +624,8 @@ TrackId TrackTracker::LegacyInternLegacyChromeAsyncTrack( // the ID's scope is global. tables::ProcessTrackTable::Row track(name); track.upid = upid; - track.classification = context_->storage->InternString( - TrackClassificationToString(TrackClassification::kUnknown)); + track.classification = + context_->storage->InternString(tracks::ToString(tracks::unknown)); track.dimension_arg_set_id = key.dimensions->arg_set_id; track.machine_id = context_->machine_id(); @@ -639,7 +644,7 @@ TrackId TrackTracker::LegacyInternLegacyChromeAsyncTrack( } StringId TrackTracker::StringIdFromTrackName( - TrackClassification classification, + tracks::TrackClassification classification, const TrackTracker::TrackName& name) { switch (name.index()) { case base::variant_index(): diff --git a/src/trace_processor/importers/common/track_tracker.h b/src/trace_processor/importers/common/track_tracker.h index 3f3571f7f0..d4d14f0f27 100644 --- a/src/trace_processor/importers/common/track_tracker.h +++ b/src/trace_processor/importers/common/track_tracker.h @@ -31,7 +31,7 @@ #include "perfetto/ext/base/string_utils.h" #include "src/trace_processor/importers/common/args_tracker.h" #include "src/trace_processor/importers/common/global_args_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/tables/metadata_tables_py.h" #include "src/trace_processor/tables/profiler_tables_py.h" @@ -187,7 +187,7 @@ class TrackTracker { // // `name` is the display name of the track in trace processor and should // always be `AutoName()` unless approved by a trace processor maintainer. - TrackId InternTrack(TrackClassification, + TrackId InternTrack(tracks::TrackClassification, std::optional, const TrackName& name = AutoName(), const SetArgsCallback& callback = {}); @@ -195,7 +195,7 @@ class TrackTracker { // Interns a track with the given classification and one dimension into the // `track` table. This is useful when interning global tracks which have a // single uncommon dimension attached to them. - TrackId InternSingleDimensionTrack(TrackClassification classification, + TrackId InternSingleDimensionTrack(tracks::TrackClassification classification, StringId key, const Variadic& value, const TrackName& name = AutoName(), @@ -206,12 +206,12 @@ class TrackTracker { // Interns counter track into TrackTable. If the track created with below // arguments already exists, returns the TrackTable::Id of the track. - TrackId InternCounterTrack(TrackClassification, + TrackId InternCounterTrack(tracks::TrackClassification, std::optional, const TrackName& = AutoName()); // Interns a unique track into the storage. - TrackId InternGlobalTrack(TrackClassification, + TrackId InternGlobalTrack(tracks::TrackClassification, const TrackName& = AutoName(), const SetArgsCallback& callback = {}); @@ -219,22 +219,22 @@ class TrackTracker { TrackId InternThreadTrack(UniqueTid, const TrackName& = AutoName()); // Interns a process track into the storage. - TrackId InternProcessTrack(TrackClassification, + TrackId InternProcessTrack(tracks::TrackClassification, UniquePid, const TrackName& = AutoName()); // Interns a global track keyed by track type + CPU into the storage. - TrackId InternCpuTrack(TrackClassification, + TrackId InternCpuTrack(tracks::TrackClassification, uint32_t cpu, const TrackName& = AutoName()); // Interns a counter track associated with a cpu into the storage. - TrackId InternCpuCounterTrack(TrackClassification, + TrackId InternCpuCounterTrack(tracks::TrackClassification, uint32_t cpu, const TrackName& = AutoName()); // Interns a counter track associated with a GPU into the storage. - TrackId InternGpuCounterTrack(TrackClassification, + TrackId InternGpuCounterTrack(tracks::TrackClassification, uint32_t gpu_id, const TrackName& = AutoName()); @@ -279,7 +279,7 @@ class TrackTracker { friend class TrackEventTracker; struct TrackMapKey { - TrackClassification classification; + tracks::TrackClassification classification; std::optional dimensions; bool operator==(const TrackMapKey& k) const { @@ -300,33 +300,35 @@ class TrackTracker { static constexpr size_t kGroupCount = static_cast(Group::kSizeSentinel); - TrackId CreateTrack(TrackClassification, + TrackId CreateTrack(tracks::TrackClassification, std::optional, const TrackName&); - TrackId CreateCounterTrack(TrackClassification, + TrackId CreateCounterTrack(tracks::TrackClassification, std::optional, const TrackName&); - TrackId CreateThreadTrack(TrackClassification, UniqueTid, const TrackName&); + TrackId CreateThreadTrack(tracks::TrackClassification, + UniqueTid, + const TrackName&); - TrackId CreateThreadCounterTrack(TrackClassification, + TrackId CreateThreadCounterTrack(tracks::TrackClassification, UniqueTid, const TrackName&); - TrackId CreateProcessTrack(TrackClassification, + TrackId CreateProcessTrack(tracks::TrackClassification, UniquePid, std::optional, const TrackName&); - TrackId CreateProcessCounterTrack(TrackClassification, + TrackId CreateProcessCounterTrack(tracks::TrackClassification, UniquePid, std::optional, const TrackName&); TrackId InternTrackForGroup(Group); - StringId StringIdFromTrackName(TrackClassification classification, + StringId StringIdFromTrackName(tracks::TrackClassification classification, const TrackTracker::TrackName& name); Dimensions SingleDimension(StringId key, const Variadic& val) { diff --git a/src/trace_processor/importers/common/tracks.h b/src/trace_processor/importers/common/tracks.h new file mode 100644 index 0000000000..d9c894fb34 --- /dev/null +++ b/src/trace_processor/importers/common/tracks.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_TRACKS_H_ +#define SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_TRACKS_H_ + +#include +#include + +namespace perfetto::trace_processor::tracks { + +// The classification of a track indicates the "type of data" the track +// contains. +// +// Every track is uniquely identified by the the combination of the +// classification and a set of dimensions: classifications allow identifying a +// set of tracks with the same type of data within the whole universe of tracks +// while dimensions allow distinguishing between different tracks in that set. +#define PERFETTO_TP_TRACKS(F) \ + F(android_energy_estimation_breakdown_per_uid) \ + F(android_energy_estimation_breakdown) \ + F(android_gpu_work_period) \ + F(android_lmk) \ + F(chrome_process_instant) \ + F(cpu_capacity) \ + F(cpu_frequency_throttle) \ + F(cpu_frequency) \ + F(cpu_funcgraph) \ + F(cpu_idle_state) \ + F(cpu_idle) \ + F(cpu_idleTime) \ + F(cpu_io_wait_time) \ + F(cpu_irq_time) \ + F(cpu_irq) \ + F(cpu_mali_irq) \ + F(cpu_max_frequency_limit) \ + F(cpu_min_frequency_limit) \ + F(cpu_napi_gro) \ + F(cpu_nice_user_time) \ + F(cpu_nr_running) \ + F(cpu_softirq_time) \ + F(cpu_softirq) \ + F(cpu_system_mode_time) \ + F(cpu_user_time) \ + F(cpu_utilization) \ + F(gpu_frequency) \ + F(interconnect_events) \ + F(irq_counter) \ + F(legacy_chrome_global_instants) \ + F(linux_device_frequency) \ + F(linux_rpm) \ + F(pkvm_hypervisor) \ + F(softirq_counter) \ + F(thread) \ + F(track_event) \ + F(triggers) \ + F(unknown) + +#define PERFETTO_TP_TRACKS_CLASSIFICATION_ENUM(name) name, +enum TrackClassification : size_t { + PERFETTO_TP_TRACKS(PERFETTO_TP_TRACKS_CLASSIFICATION_ENUM) +}; + +#define PERFETTO_TP_TRACKS_CLASSIFICATION_STR(name) #name, +constexpr std::array kTrackClassificationStr{ + PERFETTO_TP_TRACKS(PERFETTO_TP_TRACKS_CLASSIFICATION_STR)}; + +constexpr const char* ToString(TrackClassification c) { + return kTrackClassificationStr[c]; +} + +} // namespace perfetto::trace_processor::tracks + +#endif // SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_TRACKS_H_ diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc index 69974de4ff..6c1bd96ed1 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.cc +++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc @@ -46,8 +46,8 @@ #include "src/trace_processor/importers/common/process_tracker.h" #include "src/trace_processor/importers/common/system_info_tracker.h" #include "src/trace_processor/importers/common/thread_state_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/importers/ftrace/binder_tracker.h" #include "src/trace_processor/importers/ftrace/ftrace_descriptors.h" #include "src/trace_processor/importers/ftrace/ftrace_sched_event_tracker.h" @@ -1680,8 +1680,7 @@ void FtraceParser::ParseCpuFreq(int64_t timestamp, ConstBytes blob) { uint32_t cpu = freq.cpu_id(); uint32_t new_freq_khz = freq.state(); TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, cpu, - TrackTracker::LegacyCharArrayName{"cpufreq"}); + tracks::cpu_frequency, cpu, TrackTracker::LegacyCharArrayName{"cpufreq"}); context_->event_tracker->PushCounter(timestamp, new_freq_khz, track); } @@ -1690,7 +1689,7 @@ void FtraceParser::ParseCpuFreqThrottle(int64_t timestamp, ConstBytes blob) { uint32_t cpu = static_cast(freq.cpu()); double new_freq_khz = static_cast(freq.freq()); TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequencyThrottle, cpu, + tracks::cpu_frequency_throttle, cpu, TrackTracker::LegacyCharArrayName{"cpufreq_throttle"}); context_->event_tracker->PushCounter(timestamp, new_freq_khz, track); } @@ -1700,7 +1699,7 @@ void FtraceParser::ParseGpuFreq(int64_t timestamp, ConstBytes blob) { uint32_t gpu = freq.gpu_id(); uint32_t new_freq = freq.state(); TrackId track = context_->track_tracker->InternGpuCounterTrack( - TrackClassification::kGpuFrequency, gpu); + tracks::gpu_frequency, gpu); context_->event_tracker->PushCounter(timestamp, new_freq, track); } @@ -1711,7 +1710,7 @@ void FtraceParser::ParseKgslGpuFreq(int64_t timestamp, ConstBytes blob) { // Source data is frequency / 1000, so we correct that here: double new_freq = static_cast(freq.gpu_freq()) * 1000.0; TrackId track = context_->track_tracker->InternGpuCounterTrack( - TrackClassification::kGpuFrequency, gpu); + tracks::gpu_frequency, gpu); context_->event_tracker->PushCounter(timestamp, new_freq, track); } @@ -1720,8 +1719,7 @@ void FtraceParser::ParseCpuIdle(int64_t timestamp, ConstBytes blob) { uint32_t cpu = idle.cpu_id(); uint32_t new_state = idle.state(); TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuIdle, cpu, - TrackTracker::LegacyCharArrayName{"cpuidle"}); + tracks::cpu_idle, cpu, TrackTracker::LegacyCharArrayName{"cpuidle"}); context_->event_tracker->PushCounter(timestamp, new_state, track); } @@ -1876,7 +1874,7 @@ void FtraceParser::ParseLwisTracingMarkWrite(int64_t timestamp, void FtraceParser::ParseGoogleIccEvent(int64_t timestamp, ConstBytes blob) { protos::pbzero::GoogleIccEventFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kInterconnect, + tracks::interconnect_events, TrackTracker::LegacyCharArrayName(kInternconnectTrackName)); StringId slice_name_id = context_->storage->InternString(base::StringView(evt.event())); @@ -1887,7 +1885,7 @@ void FtraceParser::ParseGoogleIccEvent(int64_t timestamp, ConstBytes blob) { void FtraceParser::ParseGoogleIrmEvent(int64_t timestamp, ConstBytes blob) { protos::pbzero::GoogleIrmEventFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kInterconnect, + tracks::interconnect_events, TrackTracker::LegacyCharArrayName{kInternconnectTrackName}); StringId slice_name_id = context_->storage->InternString(base::StringView(evt.event())); @@ -2589,7 +2587,7 @@ void FtraceParser::ParseIrqHandlerEntry(uint32_t cpu, StringId slice_name_id = context_->storage->InternString(slice_name.string_view()); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kIrqCpu, cpu, + tracks::cpu_irq, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("Irq Cpu %u", cpu)}); context_->slice_tracker->Begin(timestamp, track, irq_id_, slice_name_id); @@ -2600,7 +2598,7 @@ void FtraceParser::ParseIrqHandlerExit(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::IrqHandlerExitFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kIrqCpu, cpu, + tracks::cpu_irq, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("Irq Cpu %u", cpu)}); @@ -2625,7 +2623,7 @@ void FtraceParser::ParseSoftIrqEntry(uint32_t cpu, base::StringView slice_name = kActionNames[evt.vec()]; StringId slice_name_id = context_->storage->InternString(slice_name); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kSoftirqCpu, cpu, + tracks::cpu_softirq, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("SoftIrq Cpu %u", cpu)}); context_->slice_tracker->Begin(timestamp, track, irq_id_, slice_name_id); @@ -2636,7 +2634,7 @@ void FtraceParser::ParseSoftIrqExit(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::SoftirqExitFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kSoftirqCpu, cpu, + tracks::cpu_softirq, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("SoftIrq Cpu %u", cpu)}); auto vec = evt.vec(); @@ -2898,7 +2896,7 @@ void FtraceParser::ParseNapiGroReceiveEntry(uint32_t cpu, base::StringView net_device = evt.name(); StringId slice_name_id = context_->storage->InternString(net_device); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kNapiGroCpu, cpu, + tracks::cpu_napi_gro, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("Napi Gro Cpu %u", cpu)}); auto len = evt.len(); @@ -2915,7 +2913,7 @@ void FtraceParser::ParseNapiGroReceiveExit(uint32_t cpu, protos::pbzero::NapiGroReceiveExitFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kNapiGroCpu, cpu, + tracks::cpu_napi_gro, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("Napi Gro Cpu %u", cpu)}); auto ret = evt.ret(); @@ -2932,14 +2930,14 @@ void FtraceParser::ParseCpuFrequencyLimits(int64_t timestamp, blob.size); TrackId max_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuMaxFrequencyLimit, evt.cpu_id(), + tracks::cpu_max_frequency_limit, evt.cpu_id(), TrackTracker::LegacyCharArrayName{ base::StackString<255>("Cpu %u Max Freq Limit", evt.cpu_id())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.max_freq()), max_track); TrackId min_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuMinFrequencyLimit, evt.cpu_id(), + tracks::cpu_min_frequency_limit, evt.cpu_id(), TrackTracker::LegacyCharArrayName{ base::StackString<255>("Cpu %u Min Freq Limit", evt.cpu_id())}); context_->event_tracker->PushCounter( @@ -3505,21 +3503,21 @@ void FtraceParser::ParseSchedCpuUtilCfs(int64_t timestamp, protozero::ConstBytes blob) { protos::pbzero::SchedCpuUtilCfsFtraceEvent::Decoder evt(blob.data, blob.size); TrackId util_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuUtilization, evt.cpu(), + tracks::cpu_utilization, evt.cpu(), TrackTracker::LegacyCharArrayName{ base::StackString<255>("Cpu %u Util", evt.cpu())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.cpu_util()), util_track); TrackId cap_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuCapacity, evt.cpu(), + tracks::cpu_capacity, evt.cpu(), TrackTracker::LegacyCharArrayName{ base::StackString<255>("Cpu %u Cap", evt.cpu())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.capacity()), cap_track); TrackId nrr_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuNumberRunning, evt.cpu(), + tracks::cpu_nr_running, evt.cpu(), TrackTracker::LegacyCharArrayName{ base::StackString<255>("Cpu %u Nr Running", evt.cpu())}); context_->event_tracker->PushCounter( @@ -3546,7 +3544,7 @@ void FtraceParser::ParseFuncgraphEntry( // of swapper might be running concurrently. Fall back onto global tracks // (one per cpu). track = context_->track_tracker->InternCpuTrack( - TrackClassification::kFuncgraphCpu, cpu, + tracks::cpu_funcgraph, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("swapper%u -funcgraph", cpu)}); } @@ -3571,7 +3569,7 @@ void FtraceParser::ParseFuncgraphExit( } else { // special case: see |ParseFuncgraphEntry| track = context_->track_tracker->InternCpuTrack( - TrackClassification::kFuncgraphCpu, cpu, + tracks::cpu_funcgraph, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("swapper%u -funcgraph", cpu)}); } @@ -3661,7 +3659,7 @@ void FtraceParser::ParseRpmStatus(int64_t ts, protozero::ConstBytes blob) { std::string device_name = rpm_event.name().ToStdString(); StringId device_name_string_id = context_->storage->InternString(device_name); TrackId track_id = context_->track_tracker->InternSingleDimensionTrack( - TrackClassification::kLinuxRuntimePowerManagement, linux_device_name_id_, + tracks::linux_rpm, linux_device_name_id_, Variadic::String(device_name_string_id), TrackTracker::LegacyStringIdName{device_name_string_id}); @@ -3815,7 +3813,7 @@ void FtraceParser::ParseDeviceFrequency(int64_t ts, TrackTracker::Dimensions dims_id = std::move(dims_builder).Build(); TrackId track_id = context_->track_tracker->InternCounterTrack( - TrackClassification::kLinuxDeviceFrequency, dims_id); + tracks::linux_device_frequency, dims_id); context_->event_tracker->PushCounter(ts, static_cast(event.freq()), track_id); } diff --git a/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc b/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc index ac294d3ae0..922b21ed3c 100644 --- a/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc +++ b/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc @@ -25,8 +25,8 @@ #include "src/trace_processor/importers/common/async_track_set_tracker.h" #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_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/tables/slice_tables_py.h" @@ -44,8 +44,7 @@ void GpuWorkPeriodTracker::ParseGpuWorkPeriodEvent(int64_t timestamp, dims_builder.AppendGpu(evt.gpu_id()); dims_builder.AppendUid(static_cast(evt.uid())); TrackId track_id = context_->track_tracker->InternTrack( - TrackClassification::kAndroidGpuWorkPeriod, - std::move(dims_builder).Build()); + tracks::android_gpu_work_period, std::move(dims_builder).Build()); const auto duration = static_cast(evt.end_time_ns() - evt.start_time_ns()); diff --git a/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc b/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc index cedd4125b8..44c8d9fdad 100644 --- a/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc +++ b/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc @@ -155,7 +155,7 @@ void MaliGpuEventTracker::ParseMaliGpuIrqEvent(int64_t ts, // associated to a single process or thread. Add to a custom Mali Irq track // instead. TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kMaliIrqCpu, cpu, + tracks::cpu_mali_irq, cpu, TrackTracker::LegacyCharArrayName{ base::StackString<255>("Mali Irq Cpu %u", cpu)}); diff --git a/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc b/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc index 6718b2f235..cf0d7f2b4c 100644 --- a/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc +++ b/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc @@ -85,14 +85,14 @@ void PkvmHypervisorCpuTracker::ParseHypEvent(uint32_t cpu, void PkvmHypervisorCpuTracker::ParseHypEnter(uint32_t cpu, int64_t timestamp) { // TODO(b/249050813): handle bad events (e.g. 2 hyp_enter in a row) TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); + tracks::pkvm_hypervisor, cpu, GetTrackName(cpu)); context_->slice_tracker->Begin(timestamp, track_id, category_, slice_name_); } void PkvmHypervisorCpuTracker::ParseHypExit(uint32_t cpu, int64_t timestamp) { // TODO(b/249050813): handle bad events (e.g. 2 hyp_exit in a row) TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); + tracks::pkvm_hypervisor, cpu, GetTrackName(cpu)); context_->slice_tracker->End(timestamp, track_id); } @@ -100,7 +100,7 @@ void PkvmHypervisorCpuTracker::ParseHostHcall(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::HostHcallFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); + tracks::pkvm_hypervisor, cpu, GetTrackName(cpu)); auto args_inserter = [this, &evt](ArgsTracker::BoundInserter* inserter) { StringId host_hcall = context_->storage->InternString("host_hcall"); @@ -118,7 +118,7 @@ void PkvmHypervisorCpuTracker::ParseHostSmc(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::HostSmcFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); + tracks::pkvm_hypervisor, cpu, GetTrackName(cpu)); auto args_inserter = [this, &evt](ArgsTracker::BoundInserter* inserter) { StringId host_smc = context_->storage->InternString("host_smc"); @@ -136,7 +136,7 @@ void PkvmHypervisorCpuTracker::ParseHostMemAbort(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::HostMemAbortFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); + tracks::pkvm_hypervisor, cpu, GetTrackName(cpu)); auto args_inserter = [this, &evt](ArgsTracker::BoundInserter* inserter) { StringId host_mem_abort = context_->storage->InternString("host_mem_abort"); diff --git a/src/trace_processor/importers/json/json_trace_parser_impl.cc b/src/trace_processor/importers/json/json_trace_parser_impl.cc index 601008b0b2..1890498578 100644 --- a/src/trace_processor/importers/json/json_trace_parser_impl.cc +++ b/src/trace_processor/importers/json/json_trace_parser_impl.cc @@ -289,8 +289,7 @@ void JsonTraceParserImpl::ParseJsonPacket(int64_t timestamp, TrackId track_id; if (scope == "g") { track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant, - TrackTracker::AutoName(), + tracks::legacy_chrome_global_instants, TrackTracker::AutoName(), [this](ArgsTracker::BoundInserter& inserter) { inserter.AddArg( context_->storage->InternString("source"), @@ -303,7 +302,7 @@ void JsonTraceParserImpl::ParseJsonPacket(int64_t timestamp, } UniquePid upid = context_->process_tracker->GetOrCreateProcess(pid); track_id = context_->track_tracker->InternProcessTrack( - TrackClassification::kChromeProcessInstant, upid); + tracks::chrome_process_instant, upid); context_->args_tracker->AddArgsTo(track_id).AddArg( context_->storage->InternString("source"), Variadic::String(context_->storage->InternString("chrome"))); diff --git a/src/trace_processor/importers/proto/android_probes_parser.cc b/src/trace_processor/importers/proto/android_probes_parser.cc index 4209003032..2da16c94f5 100644 --- a/src/trace_processor/importers/proto/android_probes_parser.cc +++ b/src/trace_processor/importers/proto/android_probes_parser.cc @@ -35,8 +35,8 @@ #include "src/trace_processor/importers/common/metadata_tracker.h" #include "src/trace_processor/importers/common/process_tracker.h" #include "src/trace_processor/importers/common/slice_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/importers/proto/android_probes_tracker.h" #include "src/trace_processor/storage/metadata.h" #include "src/trace_processor/storage/stats.h" @@ -213,8 +213,8 @@ void AndroidProbesParser::ParseEnergyBreakdown(int64_t ts, ConstBytes blob) { auto ordinal = energy_consumer_specs->ordinal; TrackId energy_track = context_->track_tracker->InternSingleDimensionTrack( - TrackClassification::kAndroidEnergyEstimationBreakdown, - energy_consumer_id_, Variadic::Integer(consumer_id), + tracks::android_energy_estimation_breakdown, energy_consumer_id_, + Variadic::Integer(consumer_id), TrackTracker::LegacyStringIdName{consumer_name}, [&](ArgsTracker::BoundInserter& inserter) { inserter.AddArg(consumer_type_id_, Variadic::String(consumer_type)); @@ -238,7 +238,7 @@ void AndroidProbesParser::ParseEnergyBreakdown(int64_t ts, ConstBytes blob) { builder.AppendDimension(energy_consumer_id_, Variadic::Integer(consumer_id)); TrackId energy_uid_track = context_->track_tracker->InternTrack( - TrackClassification::kAndroidEnergyEstimationBreakdownPerUid, + tracks::android_energy_estimation_breakdown_per_uid, std::move(builder).Build(), TrackTracker::LegacyStringIdName{consumer_name}); context_->event_tracker->PushCounter( diff --git a/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc b/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc index f2e98b9cc8..27296bab90 100644 --- a/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc +++ b/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc @@ -171,7 +171,7 @@ void MemoryTrackerSnapshotParser::EmitRows(int64_t ts, // For now, we use the existing global instant event track for chrome events, // since memory dumps are global. TrackId track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant, TrackTracker::AutoName(), + tracks::legacy_chrome_global_instants, TrackTracker::AutoName(), [this](ArgsTracker::BoundInserter& inserter) { inserter.AddArg( context_->storage->InternString("source"), diff --git a/src/trace_processor/importers/proto/metadata_module.cc b/src/trace_processor/importers/proto/metadata_module.cc index f2b1837178..c82b01fe51 100644 --- a/src/trace_processor/importers/proto/metadata_module.cc +++ b/src/trace_processor/importers/proto/metadata_module.cc @@ -105,8 +105,7 @@ 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( - TrackClassification::kTrigger, - TrackTracker::LegacyCharArrayName("Trace Triggers")); + tracks::triggers, TrackTracker::LegacyCharArrayName("Trace Triggers")); StringId name_id = context_->storage->InternString(trigger.trigger_name()); context_->slice_tracker->Scoped( ts, track_id, cat_id, name_id, @@ -129,7 +128,7 @@ void MetadataModule::ParseChromeTrigger(int64_t ts, ConstBytes blob) { protos::pbzero::ChromeTrigger::Decoder trigger(blob.data, blob.size); StringId cat_id = kNullStringId; TrackId track_id = - context_->track_tracker->InternGlobalTrack(TrackClassification::kTrigger); + context_->track_tracker->InternGlobalTrack(tracks::triggers); StringId name_id; if (trigger.has_trigger_name()) { name_id = context_->storage->InternString(trigger.trigger_name()); diff --git a/src/trace_processor/importers/proto/system_probes_parser.cc b/src/trace_processor/importers/proto/system_probes_parser.cc index f3508eac7e..8d4bd843cb 100644 --- a/src/trace_processor/importers/proto/system_probes_parser.cc +++ b/src/trace_processor/importers/proto/system_probes_parser.cc @@ -43,8 +43,8 @@ #include "src/trace_processor/importers/common/metadata_tracker.h" #include "src/trace_processor/importers/common/process_tracker.h" #include "src/trace_processor/importers/common/system_info_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/importers/syscalls/syscall_tracker.h" #include "src/trace_processor/storage/metadata.h" #include "src/trace_processor/storage/stats.h" @@ -350,8 +350,7 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { uint32_t c = 0; for (auto it = sys_stats.cpufreq_khz(); it; ++it, ++c) { TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, c, - TrackTracker::LegacyCharArrayName{"cpufreq"}); + tracks::cpu_frequency, c, TrackTracker::LegacyCharArrayName{"cpufreq"}); context_->event_tracker->PushCounter(ts, static_cast(*it), track); } @@ -378,43 +377,43 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { } TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kUserTime, ct.cpu_id(), + tracks::cpu_user_time, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.user_ns"}); context_->event_tracker->PushCounter(ts, static_cast(ct.user_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kNiceUserTime, ct.cpu_id(), + tracks::cpu_nice_user_time, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.user_nice_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.user_nice_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kSystemModeTime, ct.cpu_id(), + tracks::cpu_system_mode_time, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.system_mode_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.system_mode_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuIdleTime, ct.cpu_id(), + tracks::cpu_idleTime, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.idle_ns"}); context_->event_tracker->PushCounter(ts, static_cast(ct.idle_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kIoWaitTime, ct.cpu_id(), + tracks::cpu_io_wait_time, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.io_wait_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.io_wait_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kIrqTime, ct.cpu_id(), + tracks::cpu_irq_time, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.irq_ns"}); context_->event_tracker->PushCounter(ts, static_cast(ct.irq_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kSoftIrqTime, ct.cpu_id(), + tracks::cpu_softirq_time, ct.cpu_id(), TrackTracker::LegacyCharArrayName{"cpu.times.softirq_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.softirq_ns()), track); @@ -423,7 +422,7 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { for (auto it = sys_stats.num_irq(); it; ++it) { protos::pbzero::SysStats::InterruptCount::Decoder ic(*it); TrackId track = context_->track_tracker->InternSingleDimensionTrack( - TrackClassification::kIrqCounter, irq_id_, Variadic::Integer(ic.irq()), + tracks::irq_counter, irq_id_, Variadic::Integer(ic.irq()), TrackTracker::LegacyCharArrayName{"num_irq"}); context_->event_tracker->PushCounter(ts, static_cast(ic.count()), track); @@ -432,8 +431,7 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { for (auto it = sys_stats.num_softirq(); it; ++it) { protos::pbzero::SysStats::InterruptCount::Decoder ic(*it); TrackId track = context_->track_tracker->InternSingleDimensionTrack( - TrackClassification::kSoftirqCounter, irq_id_, - Variadic::Integer(ic.irq()), + tracks::softirq_counter, irq_id_, Variadic::Integer(ic.irq()), TrackTracker::LegacyCharArrayName{"num_softirq"}); context_->event_tracker->PushCounter(ts, static_cast(ic.count()), track); diff --git a/src/trace_processor/importers/proto/track_event_parser.cc b/src/trace_processor/importers/proto/track_event_parser.cc index 802854a3f5..299ccf3b35 100644 --- a/src/trace_processor/importers/proto/track_event_parser.cc +++ b/src/trace_processor/importers/proto/track_event_parser.cc @@ -516,8 +516,7 @@ class TrackEventParser::EventImporter { break; case LegacyEvent::SCOPE_GLOBAL: track_id_ = context_->track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant, - TrackTracker::AutoName(), + tracks::legacy_chrome_global_instants, TrackTracker::AutoName(), [this](ArgsTracker::BoundInserter& inserter) { inserter.AddArg( context_->storage->InternString("source"), @@ -534,7 +533,7 @@ class TrackEventParser::EventImporter { } track_id_ = context_->track_tracker->InternProcessTrack( - TrackClassification::kChromeProcessInstant, *upid_); + tracks::chrome_process_instant, *upid_); context_->args_tracker->AddArgsTo(track_id_).AddArg( context_->storage->InternString("source"), Variadic::String(context_->storage->InternString("chrome"))); diff --git a/src/trace_processor/importers/proto/track_event_tracker.cc b/src/trace_processor/importers/proto/track_event_tracker.cc index 70102189ed..5e40b113d0 100644 --- a/src/trace_processor/importers/proto/track_event_tracker.cc +++ b/src/trace_processor/importers/proto/track_event_tracker.cc @@ -31,8 +31,8 @@ #include "src/trace_processor/importers/common/args_tracker.h" #include "src/trace_processor/importers/common/process_track_translation_table.h" #include "src/trace_processor/importers/common/process_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/storage/stats.h" #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/types/trace_processor_context.h" @@ -172,16 +172,15 @@ TrackId TrackEventTracker::CreateTrackFromResolved( return it->second; } TrackId id = context_->track_tracker->CreateThreadTrack( - TrackClassification::kTrackEvent, track.utid(), - TrackTracker::AutoName()); + tracks::track_event, track.utid(), TrackTracker::AutoName()); thread_tracks_[track.utid()] = id; return id; } return context_->track_tracker->InternThreadTrack(track.utid()); } case ResolvedDescriptorTrack::Scope::kProcess: - return context_->track_tracker->InternProcessTrack( - TrackClassification::kTrackEvent, track.upid()); + return context_->track_tracker->InternProcessTrack(tracks::track_event, + track.upid()); case ResolvedDescriptorTrack::Scope::kGlobal: // Will be handled below. break; @@ -192,34 +191,30 @@ TrackId TrackEventTracker::CreateTrackFromResolved( switch (track.scope()) { case ResolvedDescriptorTrack::Scope::kThread: return context_->track_tracker->CreateThreadCounterTrack( - TrackClassification::kTrackEvent, track.utid(), - TrackTracker::AutoName()); + tracks::track_event, track.utid(), TrackTracker::AutoName()); case ResolvedDescriptorTrack::Scope::kProcess: return context_->track_tracker->CreateProcessCounterTrack( - TrackClassification::kTrackEvent, track.upid(), std::nullopt, + tracks::track_event, track.upid(), std::nullopt, TrackTracker::AutoName()); case ResolvedDescriptorTrack::Scope::kGlobal: return context_->track_tracker->CreateCounterTrack( - TrackClassification::kTrackEvent, std::nullopt, - TrackTracker::AutoName()); + tracks::track_event, std::nullopt, TrackTracker::AutoName()); } } switch (track.scope()) { case ResolvedDescriptorTrack::Scope::kThread: { return context_->track_tracker->CreateThreadTrack( - TrackClassification::kTrackEvent, track.utid(), - TrackTracker::AutoName()); + tracks::track_event, track.utid(), TrackTracker::AutoName()); } case ResolvedDescriptorTrack::Scope::kProcess: { return context_->track_tracker->CreateProcessTrack( - TrackClassification::kTrackEvent, track.upid(), std::nullopt, + tracks::track_event, track.upid(), std::nullopt, TrackTracker::AutoName()); } case ResolvedDescriptorTrack::Scope::kGlobal: { return context_->track_tracker->CreateTrack( - TrackClassification::kTrackEvent, std::nullopt, - TrackTracker::AutoName()); + tracks::track_event, std::nullopt, TrackTracker::AutoName()); } } PERFETTO_FATAL("For GCC"); diff --git a/src/trace_processor/importers/systrace/systrace_line_parser.cc b/src/trace_processor/importers/systrace/systrace_line_parser.cc index 863cb069e2..2c06136a0e 100644 --- a/src/trace_processor/importers/systrace/systrace_line_parser.cc +++ b/src/trace_processor/importers/systrace/systrace_line_parser.cc @@ -137,7 +137,7 @@ util::Status SystraceLineParser::ParseLine(const SystraceLine& line) { } TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, event_cpu.value(), + tracks::cpu_frequency, event_cpu.value(), TrackTracker::LegacyCharArrayName{"cpufreq"}); context_->event_tracker->PushCounter(line.ts, new_state.value(), track); } else if (line.event_name == "cpu_idle") { @@ -151,7 +151,7 @@ util::Status SystraceLineParser::ParseLine(const SystraceLine& line) { } TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuIdle, event_cpu.value()); + tracks::cpu_idle, event_cpu.value()); context_->event_tracker->PushCounter(line.ts, new_state.value(), track); } else if (line.event_name == "binder_transaction") { auto id = base::StringToInt32(args["transaction"]); diff --git a/src/trace_processor/importers/systrace/systrace_parser.cc b/src/trace_processor/importers/systrace/systrace_parser.cc index 9b4dee1941..c88f4c5269 100644 --- a/src/trace_processor/importers/systrace/systrace_parser.cc +++ b/src/trace_processor/importers/systrace/systrace_parser.cc @@ -23,8 +23,8 @@ #include "src/trace_processor/importers/common/event_tracker.h" #include "src/trace_processor/importers/common/process_tracker.h" #include "src/trace_processor/importers/common/slice_tracker.h" -#include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/importers/common/track_tracker.h" +#include "src/trace_processor/importers/common/tracks.h" #include "src/trace_processor/storage/trace_storage.h" namespace perfetto { @@ -272,7 +272,7 @@ void SystraceParser::ParseSystracePoint( UniquePid killed_upid = context_->process_tracker->GetOrCreateProcess(killed_pid); TrackId track = context_->track_tracker->InternProcessTrack( - TrackClassification::kAndroidLmk, killed_upid); + tracks::android_lmk, killed_upid); context_->slice_tracker->Scoped(ts, track, kNullStringId, lmk_id_, 0); } // TODO(lalitm): we should not add LMK events to the counters table @@ -335,7 +335,7 @@ void SystraceParser::PostProcessSpecialSliceBegin(int64_t ts, // Add mem.lmk instant event for consistency with other methods. TrackId track = context_->track_tracker->InternProcessTrack( - TrackClassification::kAndroidLmk, killed_upid); + tracks::android_lmk, killed_upid); context_->slice_tracker->Scoped(ts, track, kNullStringId, lmk_id_, 0); } } diff --git a/ui/src/plugins/dev.perfetto.AsyncSlices/index.ts b/ui/src/plugins/dev.perfetto.AsyncSlices/index.ts index 21ac9110bf..80f50bf775 100644 --- a/ui/src/plugins/dev.perfetto.AsyncSlices/index.ts +++ b/ui/src/plugins/dev.perfetto.AsyncSlices/index.ts @@ -112,7 +112,9 @@ class AsyncSlicePlugin implements PerfettoPlugin { and classification not in ( 'linux_rpm', 'irq_counter', - 'softirq_counter' + 'softirq_counter', + 'android_energy_estimation_breakdown', + 'android_energy_estimation_breakdown_per_uid' ) group by parent_id, name ), diff --git a/ui/src/plugins/dev.perfetto.Counter/index.ts b/ui/src/plugins/dev.perfetto.Counter/index.ts index f21f6ac4d2..76a5f32b98 100644 --- a/ui/src/plugins/dev.perfetto.Counter/index.ts +++ b/ui/src/plugins/dev.perfetto.Counter/index.ts @@ -133,10 +133,6 @@ class CounterPlugin implements PerfettoPlugin { from counter_track join _counter_track_summary using (id) where type = 'counter_track' - and classification not in ( - 'android_energy_estimation_breakdown', - 'android_energy_estimation_breakdown_per_uid' - ) union select name, id, unit from gpu_counter_track