Files
TheRock/rocm-systems/projects/rocprofiler-sdk/external/perfetto/docs/design-docs/extensions.md
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

2.9 KiB

Extensions: adding new types to traces

NOTE: extensions are work-in-progress and are not ready to be used at the moment

Currently, it is not possible to add new types to traces while using Perfetto without modifying Perfetto proto message definitions upstream.

This page describes ongoing work to use protobuf extensions in order to make it possible to define new typed messages outside of the Perfetto repository.

Protozero support

Perfetto uses its own implementation of code generation for protocol buffer messages called Protozero, which is not a full-fledged protobuf implementation. Implementation of extensions is fairly limited, and all extensions are supposed to be nested inside a message that is used in order to provide the class name for generated code.

For example,

message MyEvent {
    extend TrackEvent {
        optional string custom_string = 1000;
    }
}

Is going to generate a subclass of TrackEvent called MyEvent, that is going to have a new method to set custom_string in addition to all other protobuf fields defined in TrackEvent.

Deserialization

When analyzing traces, protos are not used directly and instead are parsed into database, which can be queried by SQL. In order to make it possible, Perfetto has to know field descriptors (the binary representation of the extended proto schema) of the extensions. Currently, the only way to do that is to add an ExtensionDescriptor packet. In the future, there is going to be a way to specify protobuf extensions at compile time in order to be able to avoid this overhead in every single trace.

However, an ability to specify extension descriptors in the trace itself will still be useful in order to be able to use a pre-compiled trace processor in the UI when adding new typed messages during local development.

Deserialization of protobuf extension are supported only for TrackEvent message at the moment, and is implemented in trace processor via ProtoToArgsUtils class. The extensions will appear in args table, similar to other trace event arguments.

Testing extensions support inside Perfetto

Perfetto trace processor is mostly tested by integration tests, where input traces are specified most frequently in textproto format. Textproto format supports extensions, but the parser has to be aware of all the extensions used. In order to make it possible, all the extensions that are used in integration tests have to be specified in the test_extensions.proto file. Since this file is only used in the testing harness and is parsed by protoc, it does not have to adhere to the convention of all extensions being inside a wrapper message, which helps with making extension identifiers more concise.