From caee32adf863f7d58ae083ffe70f347952895e55 Mon Sep 17 00:00:00 2001 From: Zim Date: Thu, 5 Oct 2023 12:30:39 +0100 Subject: [PATCH] [stdlib]: Fix monitor contention connection Fixed the isolated monitor contentions. Those that have neither parents or children. The order in which the EXCEPT and UNION was executed was incorrect previously. Test: tools/diff_test_trace_processor.py out/android/trace_processor_shell --name-filter '.*monitor.*' Change-Id: I988084b0d439e0ee596ae38ffef8b2b4571de010 --- .../stdlib/android/monitor_contention.sql | 13 ++-- .../android/android_monitor_contention.out | 65 ------------------- 2 files changed, 7 insertions(+), 71 deletions(-) diff --git a/src/trace_processor/perfetto_sql/stdlib/android/monitor_contention.sql b/src/trace_processor/perfetto_sql/stdlib/android/monitor_contention.sql index 68c8dd1702..bf280ea7bd 100644 --- a/src/trace_processor/perfetto_sql/stdlib/android/monitor_contention.sql +++ b/src/trace_processor/perfetto_sql/stdlib/android/monitor_contention.sql @@ -215,15 +215,16 @@ AND child.ts BETWEEN parent.ts AND parent.ts + parent.dur; -- Monitor contention slices that are neither blocking nor blocked by another monitor contention -- slice. They neither have |parent_id| nor |child_id| fields. CREATE TABLE internal_isolated AS -WITH - x AS ( +WITH parents_and_children AS ( + SELECT id FROM internal_children + UNION ALL + SELECT id FROM internal_parents +), isolated AS ( SELECT id FROM android_monitor_contention EXCEPT - SELECT id FROM internal_children - UNION ALL - SELECT id FROM internal_parents + SELECT id FROM parents_and_children ) -SELECT * FROM android_monitor_contention JOIN x USING (id); +SELECT * FROM android_monitor_contention JOIN isolated USING (id); -- Contains parsed monitor contention slices with the parent-child relationships. -- diff --git a/test/trace_processor/diff_tests/android/android_monitor_contention.out b/test/trace_processor/diff_tests/android/android_monitor_contention.out index b0a98949c3..43cf561a56 100644 --- a/test/trace_processor/diff_tests/android/android_monitor_contention.out +++ b/test/trace_processor/diff_tests/android/android_monitor_contention.out @@ -9454,41 +9454,6 @@ android_monitor_contention { thread_state_count: 1 } } - node { - node_id: 1303 - ts: 1737162534263 - dur: 420259 - blocking_method: "void com.android.server.am.AppProfiler.collectPssInBackground()" - blocked_method: "void com.android.server.am.ProcessProfileRecord.onProcessInactive(com.android.server.am.ProcessStatsService)" - short_blocking_method: "com.android.server.am.AppProfiler.collectPssInBackground" - short_blocked_method: "com.android.server.am.ProcessProfileRecord.onProcessInactive" - blocking_src: "AppProfiler.java:514" - blocked_src: "ProcessProfileRecord.java:349" - waiter_count: 0 - blocking_thread_name: "android.bg" - blocked_thread_name: "binder:642_14" - blocked_thread_tid: 3485 - blocking_thread_tid: 670 - process_name: "system_server" - pid: 642 - is_blocked_thread_main: false - is_blocking_thread_main: false - thread_states { - thread_state: "R" - thread_state_dur: 389378 - thread_state_count: 2 - } - thread_states { - thread_state: "R+" - thread_state_dur: 8868 - thread_state_count: 1 - } - thread_states { - thread_state: "Running" - thread_state_dur: 22013 - thread_state_count: 2 - } - } node { node_child_id: 1307 node_id: 1303 @@ -9525,36 +9490,6 @@ android_monitor_contention { thread_state_count: 2 } } - node { - node_id: 949 - ts: 1737122781871 - dur: 7301144 - blocking_method: "void com.android.server.am.AppProfiler.collectPssInBackground()" - blocked_method: "void com.android.server.am.ProcessRecord.setPid(int)" - short_blocking_method: "com.android.server.am.AppProfiler.collectPssInBackground" - short_blocked_method: "com.android.server.am.ProcessRecord.setPid" - blocking_src: "AppProfiler.java:514" - blocked_src: "ProcessRecord.java:596" - waiter_count: 0 - blocking_thread_name: "android.bg" - blocked_thread_name: "binder:642_12" - blocked_thread_tid: 2720 - blocking_thread_tid: 670 - process_name: "system_server" - pid: 642 - is_blocked_thread_main: false - is_blocking_thread_main: false - thread_states { - thread_state: "R+" - thread_state_dur: 7127675 - thread_state_count: 3 - } - thread_states { - thread_state: "Running" - thread_state_dur: 173469 - thread_state_count: 2 - } - } node { node_child_id: 956 node_id: 949