Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ AS (
OR $slice_name GLOB 'DrawFrames*'
OR $slice_name GLOB 'Texture upload*'
OR (
NOT ($slice_name GLOB '*Choreographer*')
AND NOT ($slice_name GLOB '*Input*')
AND NOT ($slice_name GLOB '*input*')
AND NOT ($slice_name GLOB 'android.os.Handler: #*')
-- Handler pattern heuristics
$slice_name GLOB '*$*'
AND (
-- Handler pattern heuristics
$slice_name GLOB '*Handler: *$*'
OR $slice_name GLOB '*.*.*: *$*'
OR $slice_name GLOB '*.*$*: #*'
)
AND NOT ($slice_name GLOB '*Choreographer*')
AND NOT ($slice_name GLOB '*Input*')
AND NOT ($slice_name GLOB '*input*')
AND NOT ($slice_name GLOB 'android.os.Handler: #*')
)
);

Expand All @@ -87,11 +88,42 @@ RETURNS BOOL
AS
SELECT _is_relevant_blocking_call_expr!($name);

-- Distinct slice names that match `_is_relevant_blocking_call_expr!`, along
-- with their standardized name and flags used by downstream tables.
-- Evaluating `android_standardize_slice_name` (which calls 3 nested Perfetto
-- functions) once per distinct matching name rather than once per `thread_slice`
-- row avoids redundant per-row function call overhead.
CREATE PERFETTO TABLE _android_critical_blocking_call_names AS
SELECT
name AS raw_name,
android_standardize_slice_name(name) AS standardized_name,
name GLOB 'DrawFrames*' AS is_draw_frames,
name GLOB 'drawLayer *' AS is_draw_layer
FROM (
SELECT DISTINCT name FROM slice WHERE _is_relevant_blocking_call_expr!(name)
);

-- Materialized thread slices matching a relevant blocking call name.
CREATE PERFETTO TABLE _android_critical_blocking_call_slices AS
SELECT
s.id,
n.standardized_name,
n.is_draw_frames,
n.is_draw_layer,
s.ts,
s.dur,
s.process_name,
s.utid,
s.upid
FROM thread_slice AS s
JOIN _android_critical_blocking_call_names AS n
ON s.name = n.raw_name;

CREATE PERFETTO TABLE _android_critical_blocking_calls_draw_frames AS
SELECT utid, id, ts, dur
FROM thread_slice
FROM _android_critical_blocking_call_slices
WHERE
name GLOB 'DrawFrames*'
is_draw_frames
ORDER BY
ts;

Expand All @@ -118,7 +150,7 @@ WITH
s.id
)
SELECT
android_standardize_slice_name(s.name) AS name,
s.standardized_name AS name,
s.ts,
iif(
wait_for_buffer_release.dur IS NULL
Expand All @@ -128,7 +160,7 @@ SELECT
) AS dur,
s.id,
s.process_name,
thread.utid,
s.utid,
s.upid,
s.ts
+ iif(
Expand All @@ -137,11 +169,8 @@ SELECT
s.dur,
MAX(s.dur - wait_for_buffer_release.dur, 0)
) AS ts_end
FROM thread_slice AS s
JOIN thread USING (utid)
FROM _android_critical_blocking_call_slices AS s
LEFT JOIN _wait_for_buffer_release_dur AS wait_for_buffer_release USING (id)
WHERE
_is_relevant_blocking_call_expr!(s.name)
UNION ALL
-- Add a summation of all drawLayer slices without the individual layer name
SELECT
Expand All @@ -150,13 +179,12 @@ SELECT
s.dur,
s.id,
s.process_name,
thread.utid,
s.utid,
s.upid,
s.ts + s.dur AS ts_end
FROM thread_slice AS s
JOIN thread USING (utid)
FROM _android_critical_blocking_call_slices AS s
WHERE
s.name GLOB 'drawLayer *'
s.is_draw_layer
UNION ALL
-- As binder names are not included in slice table, extract these directly from the
-- android_binder_txns table.
Expand Down
Loading