diff --git a/Android.bp b/Android.bp index 808b95cb95..a0b685c008 100644 --- a/Android.bp +++ b/Android.bp @@ -5481,6 +5481,7 @@ genrule { "protos/perfetto/metrics/chrome/dropped_frames.proto", "protos/perfetto/metrics/chrome/frame_times.proto", "protos/perfetto/metrics/chrome/histogram_hashes.proto", + "protos/perfetto/metrics/chrome/histogram_summaries.proto", "protos/perfetto/metrics/chrome/long_latency.proto", "protos/perfetto/metrics/chrome/media_metric.proto", "protos/perfetto/metrics/chrome/performance_mark_hashes.proto", @@ -13234,6 +13235,7 @@ genrule { "src/trace_processor/metrics/sql/chrome/chrome_args_class_names.sql", "src/trace_processor/metrics/sql/chrome/chrome_event_metadata.sql", "src/trace_processor/metrics/sql/chrome/chrome_histogram_hashes.sql", + "src/trace_processor/metrics/sql/chrome/chrome_histogram_summaries.sql", "src/trace_processor/metrics/sql/chrome/chrome_input_to_browser_intervals.sql", "src/trace_processor/metrics/sql/chrome/chrome_input_to_browser_intervals_base.sql", "src/trace_processor/metrics/sql/chrome/chrome_input_to_browser_intervals_template.sql", diff --git a/BUILD b/BUILD index 3cf2eeec91..d4d3aff147 100644 --- a/BUILD +++ b/BUILD @@ -2541,6 +2541,7 @@ perfetto_filegroup( "src/trace_processor/metrics/sql/chrome/chrome_args_class_names.sql", "src/trace_processor/metrics/sql/chrome/chrome_event_metadata.sql", "src/trace_processor/metrics/sql/chrome/chrome_histogram_hashes.sql", + "src/trace_processor/metrics/sql/chrome/chrome_histogram_summaries.sql", "src/trace_processor/metrics/sql/chrome/chrome_input_to_browser_intervals.sql", "src/trace_processor/metrics/sql/chrome/chrome_input_to_browser_intervals_base.sql", "src/trace_processor/metrics/sql/chrome/chrome_input_to_browser_intervals_template.sql", @@ -5230,6 +5231,7 @@ perfetto_proto_library( "protos/perfetto/metrics/chrome/dropped_frames.proto", "protos/perfetto/metrics/chrome/frame_times.proto", "protos/perfetto/metrics/chrome/histogram_hashes.proto", + "protos/perfetto/metrics/chrome/histogram_summaries.proto", "protos/perfetto/metrics/chrome/long_latency.proto", "protos/perfetto/metrics/chrome/media_metric.proto", "protos/perfetto/metrics/chrome/performance_mark_hashes.proto", diff --git a/protos/perfetto/metrics/chrome/BUILD.gn b/protos/perfetto/metrics/chrome/BUILD.gn index bf4788538f..c0b0c36881 100644 --- a/protos/perfetto/metrics/chrome/BUILD.gn +++ b/protos/perfetto/metrics/chrome/BUILD.gn @@ -27,6 +27,7 @@ perfetto_proto_library("@TYPE@") { "dropped_frames.proto", "frame_times.proto", "histogram_hashes.proto", + "histogram_summaries.proto", "long_latency.proto", "media_metric.proto", "performance_mark_hashes.proto", diff --git a/protos/perfetto/metrics/chrome/all_chrome_metrics.proto b/protos/perfetto/metrics/chrome/all_chrome_metrics.proto index 596bc7fca5..ebc0ac5c35 100644 --- a/protos/perfetto/metrics/chrome/all_chrome_metrics.proto +++ b/protos/perfetto/metrics/chrome/all_chrome_metrics.proto @@ -23,6 +23,7 @@ import "protos/perfetto/metrics/chrome/args_class_names.proto"; import "protos/perfetto/metrics/chrome/dropped_frames.proto"; import "protos/perfetto/metrics/chrome/frame_times.proto"; import "protos/perfetto/metrics/chrome/histogram_hashes.proto"; +import "protos/perfetto/metrics/chrome/histogram_summaries.proto"; import "protos/perfetto/metrics/chrome/long_latency.proto"; import "protos/perfetto/metrics/chrome/media_metric.proto"; import "protos/perfetto/metrics/chrome/performance_mark_hashes.proto"; @@ -53,4 +54,5 @@ extend TraceMetrics { optional ChromeUnsymbolizedArgs chrome_unsymbolized_args = 1014; optional ChromeArgsClassNames chrome_args_class_names = 1015; optional ChromeScrollJankV3 chrome_scroll_jank_v3 = 1017; + optional ChromeHistogramSummaries chrome_histogram_summaries = 1018; } diff --git a/protos/perfetto/metrics/chrome/histogram_summaries.proto b/protos/perfetto/metrics/chrome/histogram_summaries.proto new file mode 100644 index 0000000000..57dad94255 --- /dev/null +++ b/protos/perfetto/metrics/chrome/histogram_summaries.proto @@ -0,0 +1,43 @@ + +/* + * 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. + */ + +syntax = "proto2"; + +package perfetto.protos; + +message HistogramSummary { + // The name of the histogram event + optional string name = 1; + // The avarage value of the histogram event + optional int64 mean = 2; + // The number of the histogram event in the trace track + optional uint32 count = 3; + // The sum of value of the histogram event + optional int64 sum = 4; + // The maximum value of the histogram event + optional int64 max = 5; + // The 90 percentile value of the histogram event + optional int64 p90 = 6; + // The 50 percentile (median) value of the histogram event + optional int64 p50 = 7; +} + +// The list of the summary of Chrome Histograms in trace track events. +// This includes the statistic information of each histograms from Chrome. +message ChromeHistogramSummaries { + repeated HistogramSummary histogram_summary = 1; +} diff --git a/src/trace_processor/metrics/sql/chrome/BUILD.gn b/src/trace_processor/metrics/sql/chrome/BUILD.gn index 30962b821e..7d10aebe6b 100644 --- a/src/trace_processor/metrics/sql/chrome/BUILD.gn +++ b/src/trace_processor/metrics/sql/chrome/BUILD.gn @@ -26,6 +26,7 @@ perfetto_sql_source_set("chrome_sql") { "chrome_args_class_names.sql", "chrome_event_metadata.sql", "chrome_histogram_hashes.sql", + "chrome_histogram_summaries.sql", "chrome_input_to_browser_intervals.sql", "chrome_input_to_browser_intervals_base.sql", "chrome_input_to_browser_intervals_template.sql", diff --git a/src/trace_processor/metrics/sql/chrome/chrome_histogram_summaries.sql b/src/trace_processor/metrics/sql/chrome/chrome_histogram_summaries.sql new file mode 100644 index 0000000000..79464910dd --- /dev/null +++ b/src/trace_processor/metrics/sql/chrome/chrome_histogram_summaries.sql @@ -0,0 +1,49 @@ +-- +-- 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 chrome.histograms; + +DROP VIEW IF EXISTS HistogramSummaryTable; +CREATE PERFETTO VIEW HistogramSummaryTable AS +SELECT + hist.name AS histname, + CAST(AVG(hist.value) AS INTEGER) AS mean_histval, + COUNT(*) AS hist_count, + CAST(SUM(hist.value) AS INTEGER) AS sum_histval, + CAST(MAX(hist.value) AS INTEGER) AS max_histval, + CAST(PERCENTILE(hist.value, 90) AS INTEGER) AS p90_histval, + CAST(PERCENTILE(hist.value, 50) AS INTEGER) AS p50_histval +FROM chrome_histograms hist +GROUP BY hist.name; + +DROP VIEW IF EXISTS chrome_histogram_summaries_output; +CREATE PERFETTO VIEW chrome_histogram_summaries_output AS +SELECT ChromeHistogramSummaries( + 'histogram_summary', ( + SELECT RepeatedField( + HistogramSummary( + 'name', histname, + 'mean', mean_histval, + 'count', hist_count, + 'sum', sum_histval, + 'max', max_histval, + 'p90', p90_histval, + 'p50', p50_histval + ) + ) + FROM HistogramSummaryTable + ) +);