aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-05-14 19:26:40 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-14 19:26:40 +0000
commite03031ac4e69c6ec1ea1d1fd1b97c0093340a566 (patch)
tree9250b98ee9bad77c85390bfb8c03ea8e32618ec1
parentf1603603a1901086849a537ca30a8163ff6837a9 (diff)
parent832a9f1fc8e0e8cdd143585921d145c9fcc6e246 (diff)
downloadperfetto-e03031ac4e69c6ec1ea1d1fd1b97c0093340a566.tar.gz
Merge "Allow to specify which heaps to disable." am: b2927a3787 am: 22dde0839e am: 832a9f1fc8
Original change: https://android-review.googlesource.com/c/platform/external/perfetto/+/1708466 Change-Id: I3559bb9ae27011952f1c23861f1c8b39ee20ac81
-rw-r--r--protos/perfetto/config/perfetto_config.proto6
-rw-r--r--protos/perfetto/config/profiling/heapprofd_config.proto6
-rw-r--r--protos/perfetto/trace/perfetto_trace.proto6
-rw-r--r--src/profiling/memory/heapprofd_producer.cc12
-rw-r--r--src/profiling/memory/heapprofd_producer_unittest.cc13
-rw-r--r--src/profiling/memory/wire_protocol_unittest.cc11
-rw-r--r--src/trace_processor/python/perfetto/trace_processor/metrics.descriptor23
7 files changed, 68 insertions, 9 deletions
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index 529adc798..d088e9b84 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -621,6 +621,12 @@ message HeapprofdConfig {
// Introduced in Android 12.
repeated string heaps = 20;
+ // Which heaps not to sample, e.g. "libc.malloc". This is useful when used in
+ // combination with all_heaps;
+ //
+ // Introduced in Android 12.
+ repeated string exclude_heaps = 27;
+
optional bool stream_allocations = 23;
// If given, needs to be the same length as heaps and gives the sampling
diff --git a/protos/perfetto/config/profiling/heapprofd_config.proto b/protos/perfetto/config/profiling/heapprofd_config.proto
index 2d8654c65..00dd6929c 100644
--- a/protos/perfetto/config/profiling/heapprofd_config.proto
+++ b/protos/perfetto/config/profiling/heapprofd_config.proto
@@ -81,6 +81,12 @@ message HeapprofdConfig {
// Introduced in Android 12.
repeated string heaps = 20;
+ // Which heaps not to sample, e.g. "libc.malloc". This is useful when used in
+ // combination with all_heaps;
+ //
+ // Introduced in Android 12.
+ repeated string exclude_heaps = 27;
+
optional bool stream_allocations = 23;
// If given, needs to be the same length as heaps and gives the sampling
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 76638d83f..36313affd 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -621,6 +621,12 @@ message HeapprofdConfig {
// Introduced in Android 12.
repeated string heaps = 20;
+ // Which heaps not to sample, e.g. "libc.malloc". This is useful when used in
+ // combination with all_heaps;
+ //
+ // Introduced in Android 12.
+ repeated string exclude_heaps = 27;
+
optional bool stream_allocations = 23;
// If given, needs to be the same length as heaps and gives the sampling
diff --git a/src/profiling/memory/heapprofd_producer.cc b/src/profiling/memory/heapprofd_producer.cc
index 3403d3773..dfc69222c 100644
--- a/src/profiling/memory/heapprofd_producer.cc
+++ b/src/profiling/memory/heapprofd_producer.cc
@@ -149,6 +149,9 @@ bool HeapprofdConfigToClientConfiguration(
cli_config->adaptive_sampling_max_sampling_interval_bytes =
heapprofd_config.adaptive_sampling_max_sampling_interval_bytes();
size_t n = 0;
+ const std::vector<std::string>& exclude_heaps = heapprofd_config.exclude_heaps();
+ // heaps[i] and heaps_interval[i] represent that the heap named in heaps[i]
+ // should be sampled with sampling interval of heap_interval[i].
std::vector<std::string> heaps = heapprofd_config.heaps();
std::vector<uint64_t> heap_intervals =
heapprofd_config.heap_sampling_intervals();
@@ -169,6 +172,15 @@ bool HeapprofdConfigToClientConfiguration(
PERFETTO_ELOG("zero sampling interval.");
return false;
}
+ if (!exclude_heaps.empty()) {
+ // For disabled heaps, we add explicit entries but with sampling interval
+ // 0. The consumer of the sampling intervals in ClientConfiguration,
+ // GetSamplingInterval in wire_protocol.h, uses 0 to signal a heap is
+ // disabled, either because it isn't enabled (all_heaps is not set, and the
+ // heap isn't named), or because we explicitely set it here.
+ heaps.insert(heaps.end(), exclude_heaps.cbegin(), exclude_heaps.cend());
+ heap_intervals.insert(heap_intervals.end(), exclude_heaps.size(), 0u);
+ }
if (heaps.size() > base::ArraySize(cli_config->heaps)) {
heaps.resize(base::ArraySize(cli_config->heaps));
PERFETTO_ELOG("Too many heaps requested. Truncating.");
diff --git a/src/profiling/memory/heapprofd_producer_unittest.cc b/src/profiling/memory/heapprofd_producer_unittest.cc
index b1ee3f8a6..fa08e95f9 100644
--- a/src/profiling/memory/heapprofd_producer_unittest.cc
+++ b/src/profiling/memory/heapprofd_producer_unittest.cc
@@ -226,5 +226,18 @@ TEST(HeapprofdConfigToClientConfigurationTest, AllHeapsAndExplicit) {
EXPECT_EQ(cli_config.default_interval, 4096u);
}
+TEST(HeapprofdConfigToClientConfigurationTest, AllHeapsAndDisabled) {
+ HeapprofdConfig cfg;
+ cfg.set_all_heaps(true);
+ cfg.set_sampling_interval_bytes(4096);
+ cfg.add_exclude_heaps("foo");
+ ClientConfiguration cli_config;
+ ASSERT_TRUE(HeapprofdConfigToClientConfiguration(cfg, &cli_config));
+ EXPECT_EQ(cli_config.num_heaps, 1u);
+ EXPECT_STREQ(cli_config.heaps[0].name, "foo");
+ EXPECT_EQ(cli_config.heaps[0].interval, 0u);
+ EXPECT_EQ(cli_config.default_interval, 4096u);
+}
+
} // namespace profiling
} // namespace perfetto
diff --git a/src/profiling/memory/wire_protocol_unittest.cc b/src/profiling/memory/wire_protocol_unittest.cc
index 69df58fce..3f7e494dd 100644
--- a/src/profiling/memory/wire_protocol_unittest.cc
+++ b/src/profiling/memory/wire_protocol_unittest.cc
@@ -160,6 +160,17 @@ TEST(GetHeapSamplingInterval, SelectedAndDefault) {
EXPECT_EQ(GetHeapSamplingInterval(cli_config, "else"), 1u);
}
+TEST(GetHeapSamplingInterval, DisabledAndDefault) {
+ ClientConfiguration cli_config{};
+ cli_config.all_heaps = true;
+ cli_config.num_heaps = 1;
+ cli_config.default_interval = 1;
+ memcpy(cli_config.heaps[0].name, "something", sizeof("something"));
+ cli_config.heaps[0].interval = 0u;
+ EXPECT_EQ(GetHeapSamplingInterval(cli_config, "something"), 0u);
+ EXPECT_EQ(GetHeapSamplingInterval(cli_config, "else"), 1u);
+}
+
} // namespace
} // namespace profiling
} // namespace perfetto
diff --git a/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor b/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
index 2670372e1..b5e2561d5 100644
--- a/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
+++ b/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
@@ -357,8 +357,8 @@ PowerRails
name ( RnameN
energy_data ( 2-.perfetto.protos.AndroidPowerRails.EnergyDataR
energyData
-4protos/perfetto/metrics/android/startup_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto"â
+Í"
+4protos/perfetto/metrics/android/startup_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto"Ë!
AndroidStartupMetricG
startup ( 2-.perfetto.protos.AndroidStartupMetric.StartupRstartupà
TaskStateBreakdown$
@@ -409,7 +409,10 @@ HscMetricsN
Activity
name ( Rname
method ( Rmethod&
-ts_method_start (R tsMethodStartJ¯
+ts_method_start (R tsMethodStartJt
+BinderTransactionG
+duration ( 2+.perfetto.protos.AndroidStartupMetric.SliceRduration
+thread ( Rthread¯
OptimizationStatus
odex_status ( R
odexStatus-
@@ -419,7 +422,7 @@ odexStatus-
EventTimestamps'
intent_received (RintentReceived
first_frame (R
-firstFrameÀ
+firstFrame³
Startup
startup_id ( R startupId!
@@ -427,7 +430,8 @@ startup_id ( R startupId!
process_name ( R processNameN
activities ( 2..perfetto.protos.AndroidStartupMetric.ActivityR
-activities,
+activitiesq
+long_binder_transactions ( 27.perfetto.protos.AndroidStartupMetric.BinderTransactionRlongBinderTransactions,
zygote_new_process (RzygoteNewProcessC
activity_hosting_process_count ( RactivityHostingProcessCount`
event_timestamps ( 25.perfetto.protos.AndroidStartupMetric.EventTimestampsReventTimestampsX
@@ -472,11 +476,12 @@ jank_cause ( R jankCause
threadName
uid (Ruid(
uid_package_name ( RuidPackageName
-é
-Aprotos/perfetto/metrics/android/thread_time_in_state_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto"Ú
+”
+Aprotos/perfetto/metrics/android/thread_time_in_state_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto"…
AndroidThreadTimeInStateMetricU
- processes ( 27.perfetto.protos.AndroidThreadTimeInStateMetric.ProcessR processes•
-MetricsByCoreType
+ processes ( 27.perfetto.protos.AndroidThreadTimeInStateMetric.ProcessR processesÀ
+MetricsByCoreType)
+time_in_state_cpu (RtimeInStateCpu
core_type ( RcoreType
runtime_ms (R runtimeMs