Skip to content

Commit

Permalink
Merge "Re-enable Scroll Jank V3 metric in perfetto UI metrics tab." i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
Harkiran Bolaria authored and Gerrit Code Review committed Aug 31, 2023
2 parents 3a2627c + 3a53b3d commit 0042727
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 24 deletions.
1 change: 1 addition & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -10529,6 +10529,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",
Expand Down
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,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",
Expand Down
1 change: 1 addition & 0 deletions src/trace_processor/metrics/sql/chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
82 changes: 82 additions & 0 deletions src/trace_processor/metrics/sql/chrome/chrome_scroll_jank_v3.sql
Original file line number Diff line number Diff line change
@@ -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;
55 changes: 31 additions & 24 deletions test/trace_processor/diff_tests/chrome/tests_scroll_jank.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
"""))

0 comments on commit 0042727

Please sign in to comment.