Skip to content

Commit

Permalink
Merge "metrics: Add wattson estimate for marker window" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Wu authored and Gerrit Code Review committed Aug 13, 2024
2 parents 138e428 + 3393e08 commit c312416
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 5 deletions.
1 change: 1 addition & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -12957,6 +12957,7 @@ genrule {
"src/trace_processor/metrics/sql/android/sysui_update_notif_on_ui_mode_changed_metric.sql",
"src/trace_processor/metrics/sql/android/unsymbolized_frames.sql",
"src/trace_processor/metrics/sql/android/wattson_app_startup_rails.sql",
"src/trace_processor/metrics/sql/android/wattson_markers_rails.sql",
"src/trace_processor/metrics/sql/android/wattson_markers_threads.sql",
"src/trace_processor/metrics/sql/android/wattson_rail_relations.sql",
"src/trace_processor/metrics/sql/android/wattson_tasks_attribution.sql",
Expand Down
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,7 @@ perfetto_filegroup(
"src/trace_processor/metrics/sql/android/sysui_update_notif_on_ui_mode_changed_metric.sql",
"src/trace_processor/metrics/sql/android/unsymbolized_frames.sql",
"src/trace_processor/metrics/sql/android/wattson_app_startup_rails.sql",
"src/trace_processor/metrics/sql/android/wattson_markers_rails.sql",
"src/trace_processor/metrics/sql/android/wattson_markers_threads.sql",
"src/trace_processor/metrics/sql/android/wattson_rail_relations.sql",
"src/trace_processor/metrics/sql/android/wattson_tasks_attribution.sql",
Expand Down
5 changes: 4 additions & 1 deletion protos/perfetto/metrics/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ message TraceAnalysisStats {

// Root message for all Perfetto-based metrics.
//
// Next id: 74
// Next id: 75
message TraceMetrics {
reserved 4, 10, 13, 14, 16, 19;

Expand Down Expand Up @@ -334,6 +334,9 @@ message TraceMetrics {
// Android Wattson thread attribution during markers time window.
optional AndroidWattsonTasksAttributionMetric wattson_markers_threads = 73;

// Android Wattson estimate during markers time window.
optional AndroidWattsonTimePeriodMetric wattson_markers_rails = 74;

// Android
// Demo extensions.
extensions 450 to 499;
Expand Down
5 changes: 4 additions & 1 deletion protos/perfetto/metrics/perfetto_merged_metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,7 @@ message TraceAnalysisStats {

// Root message for all Perfetto-based metrics.
//
// Next id: 74
// Next id: 75
message TraceMetrics {
reserved 4, 10, 13, 14, 16, 19;

Expand Down Expand Up @@ -3208,6 +3208,9 @@ message TraceMetrics {
// Android Wattson thread attribution during markers time window.
optional AndroidWattsonTasksAttributionMetric wattson_markers_threads = 73;

// Android Wattson estimate during markers time window.
optional AndroidWattsonTimePeriodMetric wattson_markers_rails = 74;

// Android
// Demo extensions.
extensions 450 to 499;
Expand Down
7 changes: 4 additions & 3 deletions python/perfetto/trace_processor/metrics.descriptor
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ threadName!
thread_id (RthreadId

process_id (R processId
P
Q
%protos/perfetto/metrics/metrics.protoperfetto.protos8protos/perfetto/metrics/android/ad_services_metric.proto2protos/perfetto/metrics/android/android_boot.proto8protos/perfetto/metrics/android/android_boot_unagg.protoMprotos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto1protos/perfetto/metrics/android/auto_metric.protoKprotos/perfetto/metrics/android/sysui_notif_shade_list_builder_metric.protoRprotos/perfetto/metrics/android/sysui_update_notif_on_ui_mode_changed_metric.protoCprotos/perfetto/metrics/android/android_frame_timeline_metric.proto0protos/perfetto/metrics/android/anr_metric.proto1protos/perfetto/metrics/android/batt_metric.protoWprotos/perfetto/metrics/android/android_sysui_notifications_blocking_calls_metric.protoGprotos/perfetto/metrics/android/android_blocking_calls_cuj_metric.protoBprotos/perfetto/metrics/android/android_blocking_calls_unagg.proto3protos/perfetto/metrics/android/codec_metrics.proto0protos/perfetto/metrics/android/cpu_metric.proto3protos/perfetto/metrics/android/camera_metric.proto9protos/perfetto/metrics/android/camera_unagg_metric.proto5protos/perfetto/metrics/android/display_metrics.proto5protos/perfetto/metrics/android/dma_heap_metric.proto1protos/perfetto/metrics/android/dvfs_metric.proto4protos/perfetto/metrics/android/fastrpc_metric.proto0protos/perfetto/metrics/android/g2d_metric.proto0protos/perfetto/metrics/android/gpu_metric.proto0protos/perfetto/metrics/android/hwcomposer.proto1protos/perfetto/metrics/android/hwui_metric.proto/protos/perfetto/metrics/android/io_metric.proto5protos/perfetto/metrics/android/io_unagg_metric.proto0protos/perfetto/metrics/android/ion_metric.proto8protos/perfetto/metrics/android/irq_runtime_metric.proto5protos/perfetto/metrics/android/jank_cuj_metric.proto9protos/perfetto/metrics/android/java_heap_histogram.proto;protos/perfetto/metrics/android/java_heap_class_stats.proto5protos/perfetto/metrics/android/java_heap_stats.proto0protos/perfetto/metrics/android/lmk_metric.proto7protos/perfetto/metrics/android/lmk_reason_metric.proto0protos/perfetto/metrics/android/mem_metric.proto6protos/perfetto/metrics/android/mem_unagg_metric.proto6protos/perfetto/metrics/android/multiuser_metric.proto4protos/perfetto/metrics/android/network_metric.proto2protos/perfetto/metrics/android/other_traces.proto2protos/perfetto/metrics/android/package_list.proto5protos/perfetto/metrics/android/powrails_metric.proto4protos/perfetto/metrics/android/profiler_smaps.proto7protos/perfetto/metrics/android/rt_runtime_metric.proto0protos/perfetto/metrics/android/simpleperf.proto4protos/perfetto/metrics/android/startup_metric.proto4protos/perfetto/metrics/android/surfaceflinger.proto0protos/perfetto/metrics/android/task_names.proto3protos/perfetto/metrics/android/trace_quality.proto?protos/perfetto/metrics/android/android_trusty_workqueues.proto9protos/perfetto/metrics/android/unsymbolized_frames.proto3protos/perfetto/metrics/android/binder_metric.proto?protos/perfetto/metrics/android/monitor_contention_metric.protoCprotos/perfetto/metrics/android/monitor_contention_agg_metric.proto?protos/perfetto/metrics/android/app_process_starts_metric.protoAprotos/perfetto/metrics/android/android_oom_adjuster_metric.proto?protos/perfetto/metrics/android/android_broadcasts_metric.proto<protos/perfetto/metrics/android/wattson_in_time_period.proto<protos/perfetto/metrics/android/android_anomaly_metric.proto?protos/perfetto/metrics/android/wattson_tasks_attribution.proto"�
TraceMetadata*
trace_duration_ns (RtraceDurationNs
Expand Down Expand Up @@ -1518,7 +1518,7 @@ trace_uuid ( R traceUuid:
Source
SOURCE_UNKNOWN
SOURCE_TRACE
SOURCE_ANALYSIS"�-
SOURCE_ANALYSIS"�.
TraceMetricsH
android_batt ( 2%.perfetto.protos.AndroidBatteryMetricR androidBattB
android_cpu ( 2!.perfetto.protos.AndroidCpuMetricR
Expand Down Expand Up @@ -1591,5 +1591,6 @@ androidAnrw
wattson_trace_railsF ( 2/.perfetto.protos.AndroidWattsonTimePeriodMetricRwattsonTraceRailsN
android_anomalyG ( 2%.perfetto.protos.AndroidAnomalyMetricRandroidAnomalyi
wattson_trace_threadsH ( 25.perfetto.protos.AndroidWattsonTasksAttributionMetricRwattsonTraceThreadsm
wattson_markers_threadsI ( 25.perfetto.protos.AndroidWattsonTasksAttributionMetricRwattsonMarkersThreads*��*��*��*��JJ
wattson_markers_threadsI ( 25.perfetto.protos.AndroidWattsonTasksAttributionMetricRwattsonMarkersThreadsc
wattson_markers_railsJ ( 2/.perfetto.protos.AndroidWattsonTimePeriodMetricRwattsonMarkersRails*��*��*��*��JJ
 JJJJJJJ
Expand Down
1 change: 1 addition & 0 deletions src/trace_processor/metrics/sql/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ perfetto_sql_source_set("android") {
"sysui_update_notif_on_ui_mode_changed_metric.sql",
"unsymbolized_frames.sql",
"wattson_app_startup_rails.sql",
"wattson_markers_rails.sql",
"wattson_markers_threads.sql",
"wattson_rail_relations.sql",
"wattson_tasks_attribution.sql",
Expand Down
47 changes: 47 additions & 0 deletions src/trace_processor/metrics/sql/android/wattson_markers_rails.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

-- Copyright 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
--
-- https://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.

INCLUDE PERFETTO MODULE wattson.curves.ungrouped;

DROP VIEW IF EXISTS _wattson_period_windows;
CREATE PERFETTO VIEW _wattson_period_windows AS
SELECT
-- Requirement is there is exactly one pair of start/stop
(SELECT ts FROM slice WHERE name == 'wattson_start') as ts,
(SELECT ts FROM slice WHERE name == 'wattson_stop')
- (SELECT ts FROM slice WHERE name == 'wattson_start') as dur,
1 as period_id;

SELECT RUN_METRIC(
'android/wattson_rail_relations.sql',
'window_table',
'_wattson_period_windows'
);

DROP VIEW IF EXISTS wattson_markers_rails_output;
CREATE PERFETTO VIEW wattson_markers_rails_output AS
SELECT AndroidWattsonTimePeriodMetric(
'metric_version', 2,
'period_info', (
SELECT RepeatedField(
AndroidWattsonEstimateInfo(
'period_id', period_id,
'period_dur', period_dur,
'cpu_subsystem', proto
)
)
FROM _estimate_cpu_subsystem_sum
)
);
35 changes: 35 additions & 0 deletions test/trace_processor/diff_tests/metrics/android/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,38 @@ def test_wattson_markers_threads_output(self):
trace=DataPath('wattson_w_packages_Imarkers.pb'),
query=Metric("wattson_markers_threads"),
out=Path('wattson_markers_threads.out'))

def test_wattson_markers_rails_output(self):
return DiffTestBlueprint(
trace=DataPath('wattson_w_packages_Imarkers.pb'),
query=Metric("wattson_markers_rails"),
out=Csv("""
wattson_markers_rails {
metric_version: 2
period_info {
period_id: 1
period_dur: 2031870211
cpu_subsystem {
estimate_mw: 46.524994
policy0 {
estimate_mw: 34.021542
cpu0 {
estimate_mw: 14.416650
}
cpu1 {
estimate_mw: 6.641433
}
cpu2 {
estimate_mw: 8.134795
}
cpu3 {
estimate_mw: 4.828665
}
}
dsu_scu {
estimate_mw: 12.503452
}
}
}
}
"""))

0 comments on commit c312416

Please sign in to comment.