The checklists below show how to achieve some common tasks in the codebase.
format
file for your event. The location of the file depends where tracefs
is mounted but can often be found at /sys/kernel/debug/tracing/events/EVENT_GROUP/EVENT_NAME/format
.src/traced/probes/ftrace/test/data/synthetic/events/EVENT_GROUP/EVENT_NAME/format
.tools/run_ftrace_proto_gen
. This will update protos/perfetto/trace/ftrace/ftrace_event.proto
and protos/perfetto/trace/ftrace/GROUP_NAME.proto
.tools/gen_all out/YOUR_BUILD_DIRECTORY
. This will update src/traced/probes/ftrace/event_info.cc
and protos/perfetto/trace/perfetto_trace.proto
.trace_processor
is desired update src/trace_processor/importers/ftrace/ftrace_parser.cc to parse the event.Here is an example change which added the ion/ion_stat
event.
BUILD.gn
file should be updated as well.tools/gen_all out/YOUR_BUILD_DIRECTORY
. This will update the generated headers containing the descriptors for the proto.BUILD.gn
file should be updated as well.tools/ninja -C out/YOUR_BUILD_DIRECTORY
.tools/diff_test_trace_processor.py <path to trace processor binary>
.Here is an example change which added the time_in_state
metric.
tools/add_tp_diff_test.py
.tools/diff_test_trace_processor.py <path to trace processor binary>
.NOTE: all currently implemented annotations are based only on the name of the slice. It is straightforward to extend this to also consider ancestors and other similar properties; we plan on doing this in the future.
DescribeSlice
function as appropriate.SliceDescription
which is simply a pair<description, doc link>
.As derived events depend on metrics, the initial steps are same as that of developing a metric (see above).
NOTE: the metric can be just an empty proto message during prototyping or if no summarization is necessary. However, generally if an event is important enough to display in the UI, it should also be tracked in benchmarks as a metric.
To extend a metric with annotations:
<metric name>_event
.android_startup
metric, we create a view named android_startup_event
._event
suffix in the table name is important.The schema of the <metric name>_event
table/view is as follows:
Name | Type | Presence | Meaning |
---|---|---|---|
track_type | string | Mandatory | 'slice' for slices, 'counter' for counters |
track_name | string | Mandatory | Name of the track to display in the UI. Also the track identifier i.e. all events with same track_name appear on the same track. |
ts | int64 | Mandatory | The timestamp of the event (slice or counter) |
dur | int64 | Mandatory for slice, NULL for counter | The duration of the slice |
slice_name | string | Mandatory for slice, NULL for counter | The name of the slice |
value | double | Mandatory for counter, NULL for slice | The value of the counter |
0
duration slices with special rendering on the UI side.