Skip to content

Commit

Permalink
Merge "tp: Add new columns to track table for better names." into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Aug 15, 2024
2 parents 405c843 + e826088 commit 79000ce
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
35 changes: 34 additions & 1 deletion src/trace_processor/perfetto_sql/stdlib/prelude/tables_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,39 @@

INCLUDE PERFETTO MODULE prelude.views;

-- Tracks are a fundamental concept in trace processor and represent a
-- "timeline" for events of the same type and with the same context. See
-- https://perfetto.dev/docs/analysis/trace-processor#tracks for a more
-- detailed explanation, with examples.
CREATE PERFETTO VIEW track (
-- Unique identifier for this track. Identical to |track_id|, prefer using
-- |track_id| instead.
id UINT,
-- The name of the "most-specific" child table containing this row.
type STRING,
-- Name of the track; can be null for some types of tracks (e.g. thread
-- tracks).
name STRING,
-- The track which is the "parent" of this track. Only non-null for tracks
-- created using Perfetto's track_event API.
parent_id UINT,
-- 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. Alias of `args.arg_set_id`.
source_arg_set_id UINT,
-- Machine identifier, non-null for tracks on a remote machine.
machine_id UINT
) AS
SELECT
id,
type AS type,
name,
parent_id,
source_arg_set_id,
machine_id
FROM
__intrinsic_track;

-- Contains information about the CPUs on the device this trace was taken on.
CREATE PERFETTO VIEW cpu (
-- Unique identifier for this CPU. Identical to |ucpu|, prefer using |ucpu|
Expand All @@ -35,7 +68,7 @@ CREATE PERFETTO VIEW cpu (
machine_id UINT,
-- Capacity of a CPU of a device, a metric which indicates the
-- relative performance of a CPU on a device
-- For details see:
-- For details see:
-- https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpu-capacity.txt
capacity UINT
) AS
Expand Down
14 changes: 13 additions & 1 deletion src/trace_processor/tables/track_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from python.generators.trace_processor_table.public import Table
from python.generators.trace_processor_table.public import TableDoc
from python.generators.trace_processor_table.public import ColumnDoc
from python.generators.trace_processor_table.public import ColumnFlag
from python.generators.trace_processor_table.public import CppSelfTableId
from python.generators.trace_processor_table.public import CppTableId
from python.generators.trace_processor_table.public import CppUint32
Expand All @@ -30,12 +31,14 @@
TRACK_TABLE = Table(
python_module=__file__,
class_name="TrackTable",
sql_name="track",
sql_name="__intrinsic_track",
columns=[
C("name", CppString()),
C("parent_id", CppOptional(CppSelfTableId())),
C("source_arg_set_id", CppOptional(CppUint32())),
C('machine_id', CppOptional(CppTableId(MACHINE_TABLE))),
C("classification", CppOptional(CppString()), flags=ColumnFlag.HIDDEN),
C("tags", CppOptional(CppUint32()), flags=ColumnFlag.HIDDEN),
],
tabledoc=TableDoc(
doc='''
Expand Down Expand Up @@ -68,6 +71,15 @@
'''
Machine identifier, non-null for tracks on a remote machine.
''',
'classification':
'''
Classification of this track. Responsible for grouping
similar tracks together.
''',
'tags':
ColumnDoc(
doc='Additional details about the track.',
joinable='args.arg_set_id'),
}))

PROCESS_TRACK_TABLE = Table(
Expand Down

This file was deleted.

8 changes: 6 additions & 2 deletions test/trace_processor/diff_tests/parser/android/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,15 @@ def test_android_system_property_slice(self):
}
"""),
query="""
SELECT t.type, t.name, s.id, s.ts, s.dur, s.type, s.name
SELECT t.name, s.id, s.ts, s.dur, s.type, s.name
FROM track t JOIN slice s ON s.track_id = t.id
WHERE t.name = 'DeviceStateChanged';
""",
out=Path('android_system_property_slice.out'))
out=Csv("""
"name","id","ts","dur","type","name"
"DeviceStateChanged",0,1000,0,"__intrinsic_slice","some_state_from_sysprops"
"DeviceStateChanged",1,3000,0,"__intrinsic_slice","some_state_from_atrace"
"""))

def test_binder_txn_sync_good(self):
return DiffTestBlueprint(
Expand Down
2 changes: 1 addition & 1 deletion ui/src/core_plugins/async_slices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AsyncSlicePlugin implements Plugin {
count() as trackCount
from track t
join _slice_track_summary using (id)
where t.type in ('track', 'gpu_track', 'cpu_track')
where t.type in ('__intrinsic_track', 'gpu_track', 'cpu_track')
group by parent_id, name
)
select
Expand Down

0 comments on commit 79000ce

Please sign in to comment.