Skip to content

Commit

Permalink
Increase granularity of Lock contention blocking calls
Browse files Browse the repository at this point in the history
This will allow to distinguish which specific lock contention slice that is happening during Android CUJs

Bug: 322743644
Test: tools/diff_test_trace_processor.py out/linux_clang_release/trace_processor_shell
Change-Id: Iedab698140326db5be3dbe494e8d5a8c775dee65
  • Loading branch information
nicomazz committed Jan 29, 2024
1 parent 332b581 commit 04f8f8a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/trace_processor/perfetto_sql/stdlib/android/slices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ CREATE PERFETTO FUNCTION android_standardize_slice_name(
RETURNS STRING AS
SELECT
CASE
WHEN $name GLOB "Lock contention on*" THEN "Lock contention on <...>"
WHEN $name GLOB "monitor contention with*" THEN "monitor contention with <...>"
WHEN $name GLOB "SuspendThreadByThreadId*" THEN "SuspendThreadByThreadId <...>"
WHEN $name GLOB "LoadApkAssetsFd*" THEN "LoadApkAssetsFd <...>"
Expand All @@ -49,6 +48,9 @@ SELECT
WHEN $name GLOB "OpenDexFilesFromOat*" THEN "OpenDexFilesFromOat"
WHEN $name GLOB "Open oat file*" THEN "Open oat file"
WHEN $name GLOB "GC: Wait For*" THEN "Garbage Collector"
-- E.g. Lock contention on thread list lock (owner tid: 1665)
-- To: Lock contention on thread list lock <...>
WHEN $name GLOB "Lock contention on* (*" THEN substr($name, 0, instr($name, "(")) || "<...>"
-- Top level handlers slices heuristics:
-- E.g. android.os.Handler: com.android.systemui.qs.external.TileServiceManager$1
-- To: Handler: com.android.systemui.qs.external.TileServiceManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ android_blocking_calls_cuj_metric {
pid: 3000
}
ts: 2000000
dur: 240000000
dur: 260000000
blocking_calls {
name: "Contending for pthread mutex"
cnt: 1
Expand Down Expand Up @@ -132,7 +132,27 @@ android_blocking_calls_cuj_metric {
min_dur_ns: 10000000
}
blocking_calls {
name: "Lock contention on <...>"
name: "Lock contention on a monitor lock <...>"
cnt: 1
total_dur_ms: 10
max_dur_ms: 10
min_dur_ms: 10
total_dur_ns: 10000000
max_dur_ns: 10000000
min_dur_ns: 10000000
}
blocking_calls {
name: "Lock contention on thread list lock <...>"
cnt: 1
total_dur_ms: 10
max_dur_ms: 10
min_dur_ms: 10
total_dur_ns: 10000000
max_dur_ns: 10000000
min_dur_ns: 10000000
}
blocking_calls {
name: "Lock contention on thread suspend count lock <...>"
cnt: 1
total_dur_ms: 10
max_dur_ms: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
'monitor contention with something else', 'SuspendThreadByThreadId 123',
'LoadApkAssetsFd 123', 'binder transaction', 'inflate',
'Lock contention on thread list lock (owner tid: 1665)',
"Lock contention on thread suspend count lock (owner tid: 0)",
"Lock contention on a monitor lock (owner tid: 0)",
'android.os.Handler: kotlinx.coroutines.CancellableContinuationImpl',
'relayoutWindow*', 'measure', 'layout', 'configChanged',
'Contending for pthread mutex', 'ImageDecoder#decodeBitmap',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

slices_to_standardize = [
"Lock contention on thread list lock (owner tid: 1665)",
"Lock contention on thread suspend count lock (owner tid: 0)",
"Lock contention on a monitor lock (owner tid: 0)",
"monitor contention with owner BG Thread #1 (30) at",
"SuspendThreadByThreadId suspended Primes-1 id=19",
"LoadApkAssetsFd({ParcelFileDescriptor: java.io.FileDescriptor@340019d})",
Expand Down
4 changes: 3 additions & 1 deletion test/trace_processor/diff_tests/stdlib/android/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def test_android_slices_standardization_for_aggregation(self):
""",
out=Csv("""
"name"
"Lock contention on <...>"
"Lock contention on thread list lock <...>"
"Lock contention on thread suspend count lock <...>"
"Lock contention on a monitor lock <...>"
"monitor contention with <...>"
"SuspendThreadByThreadId <...>"
"LoadApkAssetsFd <...>"
Expand Down

0 comments on commit 04f8f8a

Please sign in to comment.