From 3afd5fd2b5f33badd686de8c81c68a7367dbb626 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Fri, 6 Dec 2024 13:03:42 -0800 Subject: [PATCH] Add AndroidProcessMetadata to gc metric. Which provides better filtering capabilities than just process_name. Test: ./tools/diff_test_trace_processor.py out/linux_clang_debug/trace_processor_shell --name-filter '.*garbage.*' Change-Id: I2078c04daf03aaeeca457f777789eb0c02d01b62 --- ...roid_garbage_collection_unagg_metric.proto | 6 +++- .../metrics/perfetto_merged_metrics.proto | 3 ++ .../trace_processor/metrics.descriptor | 35 ++++++++++--------- .../android_garbage_collection_unagg.sql | 9 +++-- .../android_garbage_collection_unagg.out | 22 +++++++++++- 5 files changed, 54 insertions(+), 21 deletions(-) diff --git a/protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto b/protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto index 075b9a075d..47a06d4c4f 100644 --- a/protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto +++ b/protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto @@ -18,6 +18,8 @@ syntax = "proto2"; package perfetto.protos; +import "protos/perfetto/metrics/android/process_metadata.proto"; + message AndroidGarbageCollectionUnaggMetric { message GarbageCollectionEvent { // Name of thread running garbage collection. @@ -58,6 +60,8 @@ message AndroidGarbageCollectionUnaggMetric { optional int64 tid = 18; // monotonic duration of event. optional int64 gc_monotonic_dur = 19; + // Details about the process (uid, version, etc) + optional AndroidProcessMetadata process = 20; } repeated GarbageCollectionEvent gc_events = 1; -} \ No newline at end of file +} diff --git a/protos/perfetto/metrics/perfetto_merged_metrics.proto b/protos/perfetto/metrics/perfetto_merged_metrics.proto index a91b490513..8da7221b0d 100644 --- a/protos/perfetto/metrics/perfetto_merged_metrics.proto +++ b/protos/perfetto/metrics/perfetto_merged_metrics.proto @@ -337,9 +337,12 @@ message AndroidGarbageCollectionUnaggMetric { optional int64 tid = 18; // monotonic duration of event. optional int64 gc_monotonic_dur = 19; + // Details about the process (uid, version, etc) + optional AndroidProcessMetadata process = 20; } repeated GarbageCollectionEvent gc_events = 1; } + // End of protos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto // Begin of protos/perfetto/metrics/android/app_process_starts_metric.proto diff --git a/python/perfetto/trace_processor/metrics.descriptor b/python/perfetto/trace_processor/metrics.descriptor index 94f42ea7b4..8cf7955f44 100644 --- a/python/perfetto/trace_processor/metrics.descriptor +++ b/python/perfetto/trace_processor/metrics.descriptor @@ -112,10 +112,23 @@ bindAppDur intent_dur (R intentDur total_dur (RtotalDur - -Mprotos/perfetto/metrics/android/android_garbage_collection_unagg_metric.protoperfetto.protos" + +6protos/perfetto/metrics/android/process_metadata.protoperfetto.protos" +AndroidProcessMetadata +name ( Rname +uid (RuidI +package ( 2/.perfetto.protos.AndroidProcessMetadata.PackageRpackage +pid (Rpidv +Package! + package_name ( R packageName( +apk_version_code (RapkVersionCode + +debuggable (R +debuggableJJJJJ + +Mprotos/perfetto/metrics/android/android_garbage_collection_unagg_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto" #AndroidGarbageCollectionUnaggMetrich - gc_events ( 2K.perfetto.protos.AndroidGarbageCollectionUnaggMetric.GarbageCollectionEventRgcEvents + gc_events ( 2K.perfetto.protos.AndroidGarbageCollectionUnaggMetric.GarbageCollectionEventRgcEvents GarbageCollectionEvent thread_name ( R threadName! @@ -138,7 +151,8 @@ gc_int_dur (RgcIntDur gc_ts (RgcTs pid (Rpid tid (Rtid( -gc_monotonic_dur (RgcMonotonicDur +gc_monotonic_dur (RgcMonotonicDurA +process ( 2'.perfetto.protos.AndroidProcessMetadataRprocess  8protos/perfetto/metrics/android/android_boot_unagg.protoperfetto.protos?protos/perfetto/metrics/android/app_process_starts_metric.protoMprotos/perfetto/metrics/android/android_garbage_collection_unagg_metric.proto" AndroidBootUnaggv @@ -194,19 +208,6 @@ Rprotos/perfetto/metrics/android/sysui_update_notif_on_ui_mode_changed_metric.pr name ( Rname dur_ms (RdurMs dur_ns (RdurNs - -6protos/perfetto/metrics/android/process_metadata.protoperfetto.protos" -AndroidProcessMetadata -name ( Rname -uid (RuidI -package ( 2/.perfetto.protos.AndroidProcessMetadata.PackageRpackage -pid (Rpidv -Package! - package_name ( R packageName( -apk_version_code (RapkVersionCode - -debuggable (R -debuggableJJJJJ Cprotos/perfetto/metrics/android/android_frame_timeline_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto" AndroidFrameTimelineMetric! diff --git a/src/trace_processor/metrics/sql/android/android_garbage_collection_unagg.sql b/src/trace_processor/metrics/sql/android/android_garbage_collection_unagg.sql index ee54b7e039..c68f213e4f 100644 --- a/src/trace_processor/metrics/sql/android/android_garbage_collection_unagg.sql +++ b/src/trace_processor/metrics/sql/android/android_garbage_collection_unagg.sql @@ -14,6 +14,8 @@ -- limitations under the License. -- +SELECT RUN_METRIC('android/process_metadata.sql'); + INCLUDE PERFETTO MODULE android.garbage_collection; INCLUDE PERFETTO MODULE android.suspend; @@ -41,7 +43,10 @@ SELECT AndroidGarbageCollectionUnaggMetric( 'gc_ts', gc_ts, 'tid', tid, 'pid', pid, - 'gc_monotonic_dur', _extract_duration_without_suspend(gc_ts, gc_dur) - )) FROM android_garbage_collection_events + 'gc_monotonic_dur', _extract_duration_without_suspend(gc_ts, gc_dur), + 'process', metadata + )) + FROM android_garbage_collection_events + LEFT JOIN process_metadata using (upid) ) ); diff --git a/test/trace_processor/diff_tests/metrics/android/android_garbage_collection_unagg.out b/test/trace_processor/diff_tests/metrics/android/android_garbage_collection_unagg.out index b28579be5a..6ea268e900 100644 --- a/test/trace_processor/diff_tests/metrics/android/android_garbage_collection_unagg.out +++ b/test/trace_processor/diff_tests/metrics/android/android_garbage_collection_unagg.out @@ -19,6 +19,11 @@ android_garbage_collection_unagg { tid: 3185 pid: 3162 gc_monotonic_dur: 666169475 + process { + name: "com.google.android.deskclock" + uid: 10182 + pid: 3162 + } } gc_events { thread_name: "HeapTaskDaemon" @@ -40,6 +45,11 @@ android_garbage_collection_unagg { tid: 2534 pid: 2523 gc_monotonic_dur: 58870646 + process { + name: "com.google.android.apps.nexuslauncher" + uid: 10248 + pid: 2523 + } } gc_events { thread_name: "HeapTaskDaemon" @@ -56,6 +66,11 @@ android_garbage_collection_unagg { tid: 2917 pid: 2909 gc_monotonic_dur: 168393585 + process { + name: "com.google.android.apps.wellbeing" + uid: 10173 + pid: 2909 + } } gc_events { thread_name: "HeapTaskDaemon" @@ -72,5 +87,10 @@ android_garbage_collection_unagg { tid: 2865 pid: 2855 gc_monotonic_dur: 148630605 + process { + name: "com.google.android.euicc" + uid: 10141 + pid: 2855 + } } -} \ No newline at end of file +}