Skip to content

Commit

Permalink
Merge "stdlib: Add ARGSETID type" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Dec 2, 2024
2 parents f5be557 + 5730647 commit 7bead54
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 52 deletions.
3 changes: 2 additions & 1 deletion python/generators/sql_processing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
'TIMESTAMP',
'DURATION',
'ID',
'JOINID'
'JOINID',
'ARGSETID'
]

MACRO_ARG_TYPES = ['TABLEORSUBQUERY', 'EXPR', 'COLUMNNAME']
Expand Down
6 changes: 3 additions & 3 deletions src/trace_processor/perfetto_sql/stdlib/android/input.sql
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ CREATE PERFETTO VIEW android_key_events(
-- The timestamp of when the input event was processed by the system
ts TIMESTAMP,
-- Details of the input event parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand All @@ -325,7 +325,7 @@ CREATE PERFETTO VIEW android_motion_events(
-- The timestamp of when the input event was processed by the system
ts TIMESTAMP,
-- Details of the input event parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand All @@ -347,7 +347,7 @@ CREATE PERFETTO VIEW android_input_event_dispatch(
-- Event ID of the input event that was dispatched
event_id LONG,
-- Details of the input event parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ CREATE PERFETTO VIEW android_thread_slices_for_all_startups(
-- Whether it is main thread.
is_main_thread BOOL,
-- Arg set id.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Slice id.
slice_id JOINID(slice.id),
-- Name of slice.
Expand Down Expand Up @@ -254,7 +254,7 @@ RETURNS TABLE(
-- Tid of the thread with the slice.
tid LONG,
-- Arg set id.
arg_set_id LONG
arg_set_id ARGSETID
) AS
SELECT slice_id, slice_name, slice_ts, slice_dur, thread_name, tid, arg_set_id
FROM android_thread_slices_for_all_startups
Expand All @@ -276,7 +276,7 @@ RETURNS TABLE(
-- Name of the process with slice.
process STRING,
-- Arg set id.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Whether is main thread.
is_main_thread BOOL
) AS
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/perfetto_sql/stdlib/android/statsd.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CREATE PERFETTO VIEW android_statsd_atoms(
-- The duration of the slice.
dur DURATION,
-- The id of the argument set associated with this slice.
arg_set_id LONG,
arg_set_id ARGSETID,
-- The value of the CPU instruction counter at the start of the slice. This column will only be populated if thread instruction collection is enabled with track_event.
thread_instruction_count LONG,
-- The change in value of the CPU instruction counter between the start and end of the slice. This column will only be populated if thread instruction collection is enabled with track_event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CREATE PERFETTO VIEW android_inputmethod_clients(
-- Timestamp when the dump was triggered
ts TIMESTAMP,
-- Extra args parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand All @@ -41,7 +41,7 @@ CREATE PERFETTO VIEW android_inputmethod_manager_service(
-- Timestamp when the dump was triggered
ts TIMESTAMP,
-- Extra args parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand All @@ -62,7 +62,7 @@ CREATE PERFETTO VIEW android_inputmethod_service(
-- Timestamp when the dump was triggered
ts TIMESTAMP,
-- Extra args parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CREATE PERFETTO VIEW android_viewcapture(
-- Timestamp when the snapshot was triggered
ts TIMESTAMP,
-- Extra args parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CREATE PERFETTO VIEW android_windowmanager(
-- Timestamp when the snapshot was triggered
ts TIMESTAMP,
-- Extra args parsed from the proto message
arg_set_id LONG,
arg_set_id ARGSETID,
-- Raw proto message encoded in base64
base64_proto STRING,
-- String id for raw proto message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RETURNS TABLE(
-- Alias for `slice.parent_id`.
parent_id LONG,
-- Alias for `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias for `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias for `slice.thread_dur`.
Expand Down
6 changes: 3 additions & 3 deletions src/trace_processor/perfetto_sql/stdlib/chrome/tasks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ FROM slice
WHERE name GLOB "Looper.dispatch: android.view.Choreographer$FrameHandler*";

-- Extract task's posted_from information from task's arguments.
CREATE PERFETTO FUNCTION _get_posted_from(arg_set_id LONG)
CREATE PERFETTO FUNCTION _get_posted_from(arg_set_id ARGSETID)
RETURNS STRING AS
WITH posted_from as (
SELECT
Expand Down Expand Up @@ -400,7 +400,7 @@ CREATE PERFETTO VIEW chrome_scheduler_tasks(
-- Same as slice.parent_id.
parent_id LONG,
-- Same as slice.arg_set_id.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Same as slice.thread_ts.
thread_ts TIMESTAMP,
-- Same as slice.thread_dur.
Expand Down Expand Up @@ -615,7 +615,7 @@ CREATE PERFETTO VIEW chrome_tasks(
-- Alias of |slice.category|.
category STRING,
-- Alias of |slice.arg_set_id|.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias of |slice.thread_ts|.
thread_ts TIMESTAMP,
-- Alias of |slice.thread_dur|.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ CREATE PERFETTO VIEW track (
--
-- Join with the `args` table or use the `EXTRACT_ARG` helper function to
-- expand the args.
dimension_arg_set_id LONG,
dimension_arg_set_id ARGSETID,
-- The track which is the "parent" of this track. Only non-null for tracks
-- created using Perfetto's track_event API.
parent_id LONG,
parent_id JOINID(track.id),
-- Generic key-value pairs containing extra information about the track.
--
-- Join with the `args` table or use the `EXTRACT_ARG` helper function to
-- expand the args.
source_arg_set_id LONG,
source_arg_set_id ARGSETID,
-- Machine identifier, non-null for tracks on a remote machine.
machine_id LONG
) AS
Expand Down Expand Up @@ -108,7 +108,7 @@ CREATE PERFETTO VIEW cpu (
-- https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpu-capacity.txt
capacity LONG,
-- Extra key/value pairs associated with this cpu.
arg_set_id LONG
arg_set_id ARGSETID
) AS
SELECT
id,
Expand Down Expand Up @@ -253,7 +253,7 @@ CREATE PERFETTO VIEW thread_state (
-- The unique thread id of the thread which caused a wakeup of this thread.
waker_utid JOINID(thread.id),
-- The unique thread state id which caused a wakeup of this thread.
waker_id LONG,
waker_id JOINID(thread_state.id),
-- Whether the wakeup was from interrupt context or process context.
irq_context LONG,
-- The unique CPU identifier that the thread executed on.
Expand Down Expand Up @@ -296,7 +296,7 @@ CREATE PERFETTO VIEW raw (
-- The thread this event was emitted on.
utid JOINID(thread.id),
-- The set of key/value pairs associated with this event.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Ftrace event flags for this event. Currently only emitted for sched_waking
-- events.
common_flags LONG,
Expand Down Expand Up @@ -336,7 +336,7 @@ CREATE PERFETTO VIEW ftrace_event (
-- The thread this event was emitted on.
utid JOINID(thread.id),
-- The set of key/value pairs associated with this event.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Ftrace event flags for this event. Currently only emitted for
-- sched_waking events.
common_flags LONG,
Expand Down Expand Up @@ -414,7 +414,7 @@ CREATE PERFETTO VIEW cpu_track (
-- Args for this track which store information about "source" of this track in
-- the trace. For example: whether this track orginated from atrace, Chrome
-- tracepoints etc.
source_arg_set_id LONG,
source_arg_set_id ARGSETID,
-- Machine identifier, non-null for tracks on a remote machine.
machine_id LONG,
-- The CPU that the track is associated with.
Expand Down Expand Up @@ -453,14 +453,11 @@ CREATE PERFETTO TABLE counter_track (
classification STRING,
-- The dimensions of the track which uniquely identify the track within a
-- given classification.
--
-- Join with the `args` table or use the `EXTRACT_ARG` helper function to
-- expand the args.
dimension_arg_set_id LONG,
dimension_arg_set_id ARGSETID,
-- Args for this track which store information about "source" of this track in
-- the trace. For example: whether this track orginated from atrace, Chrome
-- tracepoints etc.
source_arg_set_id LONG,
source_arg_set_id ARGSETID,
-- Machine identifier, non-null for tracks on a remote machine.
machine_id LONG,
-- The units of the counter. This column is rarely filled.
Expand Down Expand Up @@ -509,7 +506,7 @@ CREATE PERFETTO TABLE cpu_counter_track (
-- Args for this track which store information about "source" of this track in
-- the trace. For example: whether this track orginated from atrace, Chrome
-- tracepoints etc.
source_arg_set_id LONG,
source_arg_set_id ARGSETID,
-- Machine identifier, non-null for tracks on a remote machine.
machine_id LONG,
-- The units of the counter. This column is rarely filled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CREATE PERFETTO VIEW counter(
-- Value.
value DOUBLE,
-- Additional information about the counter value.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Legacy column, should no longer be used.
type STRING
) AS
Expand Down Expand Up @@ -67,9 +67,9 @@ CREATE PERFETTO VIEW slice(
-- The stack_id for the parent of this slice. Rarely useful.
parent_stack_id LONG,
-- The id of the parent (i.e. immediate ancestor) slice for this slice.
parent_id LONG,
parent_id JOINID(slice.id),
-- The id of the argument set associated with this slice.
arg_set_id LONG,
arg_set_id ARGSETID,
-- The thread timestamp at the start of the slice. This column will only be
-- populated if thread timestamp collection is enabled with track_event.
thread_ts TIMESTAMP,
Expand Down Expand Up @@ -103,7 +103,7 @@ CREATE PERFETTO VIEW instant(
-- instant.
name STRING,
-- The id of the argument set associated with this instant.
arg_set_id LONG
arg_set_id ARGSETID
) AS
SELECT ts, track_id, name, arg_set_id
FROM slice
Expand Down Expand Up @@ -134,7 +134,7 @@ CREATE PERFETTO VIEW slices(
-- Alias of `slice.parent_id`.
parent_id JOINID(slice.id),
-- Alias of `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias of `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias of `slice.thread_dur`.
Expand Down Expand Up @@ -217,7 +217,7 @@ CREATE PERFETTO VIEW process(
-- /proc/cmdline for this process.
cmdline STRING,
-- Extra args for this process.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Machine identifier, non-null for processes on a remote machine.
machine_id LONG
) AS
Expand All @@ -234,7 +234,7 @@ CREATE PERFETTO VIEW args(
-- The name of the "most-specific" child table containing this row.
type STRING,
-- The id for a single set of arguments.
arg_set_id LONG,
arg_set_id ARGSETID,
-- The "flat key" of the arg: this is the key without any array indexes.
flat_key STRING,
-- The key for the arg.
Expand Down
13 changes: 6 additions & 7 deletions src/trace_processor/perfetto_sql/stdlib/sched/runnable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
-- - previous "Runnable" (or runnable preempted) state.
-- - previous uninterrupted "Runnable" state with a valid waker thread.
CREATE PERFETTO TABLE sched_previous_runnable_on_thread(
-- Alias of `thread_state.id`.
id LONG,
-- Previous runnable thread state. Alias of `thread_state.id`.
prev_runnable_id LONG,
-- Previous runnable thread state with valid waker thread. Alias of
-- `thread_state.id`.
prev_wakeup_runnable_id LONG
-- Running thread state
id JOINID(thread_state.id),
-- Previous runnable thread state.
prev_runnable_id JOINID(thread_state.id),
-- Previous runnable thread state with valid waker thread.
prev_wakeup_runnable_id JOINID(thread_state.id)
) AS
WITH running_and_runnable AS (
SELECT
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/perfetto_sql/stdlib/slices/hierarchy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RETURNS TABLE(
-- Alias of `slice.parent_id`.
parent_id JOINID(slice.id),
-- Alias of `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias of `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias of `slice.thread_dur`.
Expand Down Expand Up @@ -78,7 +78,7 @@ RETURNS TABLE(
-- Alias of `slice.parent_id`.
parent_id JOINID(slice.id),
-- Alias of `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias of `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias of `slice.thread_dur`.
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/perfetto_sql/stdlib/slices/slices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ CREATE PERFETTO VIEW _slice_with_thread_and_process_info(
-- Alias for `slice.depth`.
depth LONG,
-- Alias for `slice.parent_id`.
parent_id LONG,
parent_id JOINID(slice.id),
-- Alias for `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias for `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias for `slice.thread_dur`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CREATE PERFETTO VIEW thread_slice(
-- Alias for `slice.parent_id`.
parent_id JOINID(slice.id),
-- Alias for `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias for `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias for `slice.thread_dur`.
Expand Down Expand Up @@ -113,7 +113,7 @@ CREATE PERFETTO VIEW process_slice(
-- Alias for `slice.parent_id`.
parent_id JOINID(slice.id),
-- Alias for `slice.arg_set_id`.
arg_set_id LONG,
arg_set_id ARGSETID,
-- Alias for `slice.thread_ts`.
thread_ts TIMESTAMP,
-- Alias for `slice.thread_dur`.
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/util/sql_argument.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ std::optional<Type> ParseType(base::StringView str) {
return Type::kBool;
}
if (str.CaseInsensitiveOneOf(
{"long", "timestamp", "duration", "id", "joinid"})) {
{"long", "timestamp", "duration", "id", "joinid", "argsetid"})) {
return Type::kLong;
}
if (str.CaseInsensitiveEq("double")) {
Expand Down

0 comments on commit 7bead54

Please sign in to comment.