Skip to content

Commit

Permalink
Remove unused UMA protos to minimize Cobalt binary size increase (#1025)
Browse files Browse the repository at this point in the history
These protos were added in th PR youtube#551 for the first introduction of
Cobalt Telemetry. They are currently unused in Cobalt and removing them
seems to reduce the binary size significantly (per bloaty analysis).

Protos removed: omnibox_event.proto, sampled_profile.proto,
memory_leak.proto.

b/290819695

Change-Id: I350742ea55621b29fa3d565618098791f666c141
  • Loading branch information
joeltine authored Jul 24, 2023
1 parent ada6fce commit eb78ed1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
5 changes: 5 additions & 0 deletions components/metrics/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ static_library("metrics") {

if (use_cobalt_customizations) {
sources -= [
# Allows removal of unused sampled_profile.proto, which adds ~200KB to
# the binary. See b/290819695.
"call_stack_profile_metrics_provider.cc",
"call_stack_profile_metrics_provider.h",

# All code should be OS agnostic above SB.
"drive_metrics_provider_android.cc",
"drive_metrics_provider_ios.mm",
Expand Down
4 changes: 3 additions & 1 deletion components/metrics/metrics_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,16 @@ void MetricsLog::TruncateEvents() {
internal::kUserActionEventLimit,
uma_proto_.user_action_event_size() - internal::kUserActionEventLimit);
}

// Omnibox proto removed for binary size reasons: b/290819695.
#if !defined(USE_COBALT_CUSTOMIZATIONS)
if (uma_proto_.omnibox_event_size() > internal::kOmniboxEventLimit) {
UMA_HISTOGRAM_COUNTS_100000("UMA.TruncatedEvents.Omnibox",
uma_proto_.omnibox_event_size());
uma_proto_.mutable_omnibox_event()->DeleteSubrange(
internal::kOmniboxEventLimit,
uma_proto_.omnibox_event_size() - internal::kOmniboxEventLimit);
}
#endif
}

void MetricsLog::GetEncodedLog(std::string* encoded_log) {
Expand Down
3 changes: 3 additions & 0 deletions components/metrics/metrics_log_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ TEST_F(MetricsLogTest, TruncateEvents) {
log.RecordUserAction("BasicAction");
EXPECT_EQ(i + 1, log.uma_proto().user_action_event_size());
}
// Omnibox proto removed for binary size reasons: b/290819695.
#if !defined(USE_COBALT_CUSTOMIZATIONS)
for (int i = 0; i < internal::kOmniboxEventLimit * 2; ++i) {
// Add an empty omnibox event. Not fully realistic since these are normally
// supplied by a metrics provider.
Expand All @@ -358,6 +360,7 @@ TEST_F(MetricsLogTest, TruncateEvents) {
EXPECT_EQ(internal::kUserActionEventLimit,
log.uma_proto().user_action_event_size());
EXPECT_EQ(internal::kOmniboxEventLimit, log.uma_proto().omnibox_event_size());
#endif
}

} // namespace metrics
6 changes: 6 additions & 0 deletions components/metrics/metrics_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAtProviderRequest) {
EXPECT_TRUE(uma_log.has_session_id());
EXPECT_TRUE(uma_log.has_system_profile());
EXPECT_EQ(0, uma_log.user_action_event_size());
// Omnibox proto removed for binary size reasons: b/290819695.
#if !defined(USE_COBALT_CUSTOMIZATIONS)
EXPECT_EQ(0, uma_log.omnibox_event_size());
#endif
EXPECT_EQ(0, uma_log.perf_data_size());
CheckForNonStabilityHistograms(uma_log);

Expand Down Expand Up @@ -311,7 +314,10 @@ TEST_F(MetricsServiceTest, InitialStabilityLogAfterCrash) {
EXPECT_TRUE(uma_log.has_session_id());
EXPECT_TRUE(uma_log.has_system_profile());
EXPECT_EQ(0, uma_log.user_action_event_size());
// Omnibox proto removed for binary size reasons: b/290819695.
#if !defined(USE_COBALT_CUSTOMIZATIONS)
EXPECT_EQ(0, uma_log.omnibox_event_size());
#endif
EXPECT_EQ(0, uma_log.perf_data_size());
CheckForNonStabilityHistograms(uma_log);

Expand Down
7 changes: 7 additions & 0 deletions third_party/metrics_proto/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ proto_library("metrics_proto") {
generate_python = false

sources += [ "cobalt_uma_event.proto" ]
# Currently unused protos removed to save on binary size. See b/290819695.
sources -= [
"memory_leak_report.proto",
"omnibox_event.proto",
"omnibox_input_type.proto",
"sampled_profile.proto",
]
}
}
17 changes: 11 additions & 6 deletions third_party/metrics_proto/chrome_user_metrics_extension.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ package metrics;

import "cast_logs.proto";
import "histogram_event.proto";
import "memory_leak_report.proto";
import "omnibox_event.proto";
// Cobalt-only change to reduce compiled binary byte size. See b/290819695.
//import "memory_leak_report.proto";
//import "omnibox_event.proto";
import "perf_data.proto";
import "printer_event.proto";
import "reporting_info.proto";
import "sampled_profile.proto";
// Cobalt-only change to reduce compiled binary byte size. See b/290819695.
//import "sampled_profile.proto";
import "system_profile.proto";
import "translate_event.proto";
import "user_action_event.proto";
Expand Down Expand Up @@ -66,22 +68,25 @@ message ChromeUserMetricsExtension {

// This message will log one or more of the following event types:
repeated UserActionEventProto user_action_event = 4;
repeated OmniboxEventProto omnibox_event = 5;
// Cobalt-only change to reduce compiled binary byte size. See b/290819695.
//repeated OmniboxEventProto omnibox_event = 5;
repeated HistogramEventProto histogram_event = 6;
repeated TranslateEventProto translate_event = 15;
repeated PrinterEventProto printer_event = 16;

// Deprecated: use |sampled_profile| instead.
repeated PerfDataProto perf_data = 8 [deprecated = true];

// Cobalt-only change to reduce compiled binary byte size. See b/290819695.
// A list of all collected sample-based profiles since the last UMA upload.
repeated SampledProfile sampled_profile = 11;
//repeated SampledProfile sampled_profile = 11;

// Additional data related with Cast-enabled devices.
optional CastLogsProto cast_logs = 12;

// Cobalt-only change to reduce compiled binary byte size. See b/290819695.
// Memory leak reports generated since the last UMA upload.
repeated MemoryLeakReportProto memory_leak_report = 13;
//repeated MemoryLeakReportProto memory_leak_report = 13;

// The ReportingInfo message sent in the X-Chrome-UMA-ReportingInfo header.
// Copied in by the receiving server.
Expand Down

0 comments on commit eb78ed1

Please sign in to comment.