INCLUDE PERFETTO MODULE slices.with_context;
CREATE PERFETTO VIEW _startup_start_events AS
WITH
starts AS (
SELECT
name,
extract_arg(arg_set_id, 'startup.activity_id') AS activity_id,
ts,
dur,
upid AS browser_upid
FROM thread_slice
WHERE
name = 'Startup.ActivityStart'
),
times_to_first_visible_content AS (
SELECT
name,
extract_arg(arg_set_id, 'startup.activity_id') AS activity_id,
ts,
dur,
upid AS browser_upid
FROM process_slice
WHERE
name = 'Startup.TimeToFirstVisibleContent2'
),
all_activity_ids AS (
SELECT DISTINCT
activity_id,
browser_upid
FROM starts
UNION ALL
SELECT DISTINCT
activity_id,
browser_upid
FROM times_to_first_visible_content
),
activity_ids AS (
SELECT DISTINCT
activity_id,
browser_upid
FROM all_activity_ids
)
SELECT
activity_ids.activity_id,
'Startup' AS name,
coalesce(times_to_first_visible_content.ts, starts.ts) AS startup_begin_ts,
times_to_first_visible_content.ts + times_to_first_visible_content.dur AS first_visible_content_ts,
activity_ids.browser_upid
FROM activity_ids
LEFT JOIN times_to_first_visible_content
USING (activity_id, browser_upid)
LEFT JOIN starts
USING (activity_id, browser_upid);
CREATE PERFETTO VIEW _launch_causes AS
SELECT
extract_arg(arg_set_id, 'startup.activity_id') AS activity_id,
extract_arg(arg_set_id, 'startup.launch_cause') AS launch_cause,
upid AS browser_upid
FROM thread_slice
WHERE
name = 'Startup.LaunchCause';
CREATE PERFETTO TABLE chrome_startups (
id LONG,
activity_id LONG,
name STRING,
startup_begin_ts TIMESTAMP,
first_visible_content_ts TIMESTAMP,
launch_cause STRING,
browser_upid LONG
) AS
SELECT
row_number() OVER (ORDER BY start_events.startup_begin_ts) AS id,
start_events.activity_id,
start_events.name,
start_events.startup_begin_ts,
start_events.first_visible_content_ts,
launches.launch_cause,
start_events.browser_upid
FROM _startup_start_events AS start_events
LEFT JOIN _launch_causes AS launches
USING (activity_id, browser_upid);