From 3a53b3d241a6cd95f92e3135194d70402c5b0a0e Mon Sep 17 00:00:00 2001 From: Harkiran Bolaria Date: Wed, 30 Aug 2023 11:39:41 +0000 Subject: [PATCH] Re-enable Scroll Jank V3 metric in perfetto UI metrics tab. Dependent upon Chromium change at: https://chromium-review.googlesource.com/c/chromium/src/+/4824108 Bug: b/298153702 Change-Id: I83c933ffed36235460c8a6460c061d436ccd6b03 --- Android.bp | 1 + BUILD | 1 + .../metrics/sql/chrome/BUILD.gn | 1 + .../sql/chrome/chrome_scroll_jank_v3.sql | 82 +++++++++++++++++++ .../diff_tests/chrome/tests_scroll_jank.py | 55 +++++++------ 5 files changed, 116 insertions(+), 24 deletions(-) create mode 100644 src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql diff --git a/Android.bp b/Android.bp index aaff342568..6c48fe1a4d 100644 --- a/Android.bp +++ b/Android.bp @@ -10530,6 +10530,7 @@ genrule { "src/trace_processor/metrics/sql/chrome/chrome_scroll_inputs_per_frame.sql", "src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_caused_by_scheduling.sql", "src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v2.sql", + "src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql", "src/trace_processor/metrics/sql/chrome/chrome_slice_names.sql", "src/trace_processor/metrics/sql/chrome/chrome_stack_samples_for_task.sql", "src/trace_processor/metrics/sql/chrome/chrome_tasks.sql", diff --git a/BUILD b/BUILD index dbd0bd17ad..67142ca9ba 100644 --- a/BUILD +++ b/BUILD @@ -1965,6 +1965,7 @@ perfetto_filegroup( "src/trace_processor/metrics/sql/chrome/chrome_scroll_inputs_per_frame.sql", "src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_caused_by_scheduling.sql", "src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v2.sql", + "src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql", "src/trace_processor/metrics/sql/chrome/chrome_slice_names.sql", "src/trace_processor/metrics/sql/chrome/chrome_stack_samples_for_task.sql", "src/trace_processor/metrics/sql/chrome/chrome_tasks.sql", diff --git a/src/trace_processor/metrics/sql/chrome/BUILD.gn b/src/trace_processor/metrics/sql/chrome/BUILD.gn index 128173e396..78d7df77fa 100644 --- a/src/trace_processor/metrics/sql/chrome/BUILD.gn +++ b/src/trace_processor/metrics/sql/chrome/BUILD.gn @@ -37,6 +37,7 @@ perfetto_sql_source_set("chrome_sql") { "chrome_scroll_inputs_per_frame.sql", "chrome_scroll_jank_caused_by_scheduling.sql", "chrome_scroll_jank_v2.sql", + "chrome_scroll_jank_v3.sql", "chrome_slice_names.sql", "chrome_stack_samples_for_task.sql", "chrome_tasks.sql", diff --git a/src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql b/src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql new file mode 100644 index 0000000000..514f184eb5 --- /dev/null +++ b/src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql @@ -0,0 +1,82 @@ +-- +-- Copyright 2023 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 chrome.scroll_jank.scroll_jank_v3; + +DROP VIEW IF EXISTS chrome_scroll_jank_v3_intermediate; + +-- An "intermediate" view for computing `chrome_scroll_jank_v3_output` below. +-- +-- @column trace_num_frames The number of frames in the trace. +-- @column trace_num_janky_frames The number of delayed/janky frames in the +-- trace. +-- @column vsync_interval The standard vsync interval. +-- @column scrolls A proto amalgamation of metrics per scroll +-- including the number of frames, number of +-- janky frames, percent of janky frames, +-- maximum presentation delay, and the causes +-- of jank (cause, sub-cause, delay). +CREATE VIEW chrome_scroll_jank_v3_intermediate AS +SELECT + -- MAX does not matter for these aggregations, since the values are the + -- same across rows. + (SELECT COUNT(*) FROM chrome_janky_frame_info_with_delay) + AS trace_num_frames, + (SELECT COUNT(*) FROM chrome_janky_frames) + AS trace_num_janky_frames, + causes.vsync_interval, + RepeatedField( + ChromeScrollJankV3_Scroll( + 'num_frames', + frames.num_frames, + 'num_janky_frames', + frames.num_janky_frames, + 'scroll_jank_percentage', + frames.scroll_jank_percentage, + 'max_delay_since_last_frame', + causes.max_delay_since_last_frame, + 'scroll_jank_causes', + causes.scroll_jank_causes)) + AS scrolls +FROM + chrome_frames_per_scroll AS frames +INNER JOIN chrome_causes_per_scroll AS causes + ON frames.scroll_id = causes.scroll_id; + +DROP VIEW IF EXISTS chrome_scroll_jank_v3_output; + +-- For producing a "native" Perfetto UI metric. +-- +-- @column scroll_jank_summary A proto amalgamation summarizing all of the +-- scroll jank in a trace, including the number +-- of frames, janky frames, percentage of janky +-- frames, vsync interval, and a summary of this +-- data (including individual causes) for each +-- scroll. +CREATE VIEW chrome_scroll_jank_v3_output AS +SELECT + ChromeScrollJankV3( + 'trace_num_frames', + trace_num_frames, + 'trace_num_janky_frames', + trace_num_janky_frames, + 'trace_scroll_jank_percentage', + 100.0 * trace_num_janky_frames / trace_num_frames, + 'vsync_interval_ms', + vsync_interval, + 'scrolls', + scrolls) AS scroll_jank_summary +FROM + chrome_scroll_jank_v3_intermediate; diff --git a/test/trace_processor/diff_tests/chrome/tests_scroll_jank.py b/test/trace_processor/diff_tests/chrome/tests_scroll_jank.py index 208409ccac..8e88fc5407 100644 --- a/test/trace_processor/diff_tests/chrome/tests_scroll_jank.py +++ b/test/trace_processor/diff_tests/chrome/tests_scroll_jank.py @@ -662,28 +662,35 @@ def test_chrome_scroll_jank_v2_without_sub_cause(self): def test_chrome_scroll_jank_v3(self): return DiffTestBlueprint( trace=DataPath('chrome_input_with_frame_view.pftrace'), - query=""" - SELECT IMPORT('chrome.scroll_jank.scroll_jank_v3'); - - SELECT - (SELECT COUNT(*) FROM chrome_janky_frame_info_with_delay) - AS trace_num_frames, - (SELECT COUNT(*) FROM chrome_janky_frames) - AS trace_num_janky_frames, - causes.vsync_interval, - frames.num_frames, - frames.num_janky_frames, - frames.scroll_jank_percentage, - causes.max_delay_since_last_frame, - c.cause_of_jank, - c.delay_since_last_frame - FROM chrome_frames_per_scroll AS frames - INNER JOIN chrome_causes_per_scroll AS causes USING(scroll_id) - INNER JOIN chrome_janky_frames c USING (scroll_id) - """, - out=Csv(""" - "trace_num_frames","trace_num_janky_frames","vsync_interval","num_frames","num_janky_frames","scroll_jank_percentage","max_delay_since_last_frame","cause_of_jank","delay_since_last_frame" - 291,3,16.368000,105,2,1.904762,6.126222,"[NULL]",33.462000 - 291,3,16.368000,105,2,1.904762,6.126222,"RendererCompositorFinishedToBeginImplFrame",100.274000 - 291,3,16.368000,84,1,1.190476,2.040811,"RendererCompositorQueueingDelay",33.404000 + query=Metric('chrome_scroll_jank_v3'), + out=TextProto(r""" + [perfetto.protos.chrome_scroll_jank_v3] { + trace_num_frames: 291 + trace_num_janky_frames: 3 + trace_scroll_jank_percentage: 1.0309278350515463 + vsync_interval_ms: 16.368 + scrolls { + num_frames: 105 + num_janky_frames: 2 + scroll_jank_percentage: 1.9047619047619047 + max_delay_since_last_frame: 6.126221896383187 + scroll_jank_causes { + delay_since_last_frame: 2.044354838709678 + } + scroll_jank_causes { + cause: "RendererCompositorFinishedToBeginImplFrame" + delay_since_last_frame: 6.126221896383187 + } + } + scrolls { + num_frames: 84 + num_janky_frames: 1 + scroll_jank_percentage: 1.1904761904761905 + max_delay_since_last_frame: 2.040811339198436 + scroll_jank_causes { + cause: "RendererCompositorQueueingDelay" + delay_since_last_frame: 2.040811339198436 + } + } + } """))