Skip to content

Commit

Permalink
Merge "Implement a Chrome histogram summary metric in Perfetto." into…
Browse files Browse the repository at this point in the history
… main
  • Loading branch information
mhiramat authored and Gerrit Code Review committed Nov 15, 2024
2 parents 24c7770 + 5e8f9a7 commit daeb5b9
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions protos/perfetto/metrics/chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions protos/perfetto/metrics/chrome/all_chrome_metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
43 changes: 43 additions & 0 deletions protos/perfetto/metrics/chrome/histogram_summaries.proto
Original file line number Diff line number Diff line change
@@ -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;
}
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 @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
);

0 comments on commit daeb5b9

Please sign in to comment.