How to send a complex custom data source event

30 views
Skip to first unread message

Jacob Ignatius

unread,
Jun 5, 2025, 6:20:43 PMJun 5
to Perfetto Development - www.perfetto.dev
Hi.

I have defined my own custom data source message:

syntax = "proto3";

package gpu.metrics;

message GpuPerformanceMetrics {
uint64 gpu_active_cycles = 1;
uint64 gpu_interrupt_pending_cycles = 2;
uint64 fragment_jobs = 3;
uint64 fragment_tasks = 4;
uint64 fragment_queue_active_cycles = 5;
uint64 non_fragment_jobs = 6;
uint64 non_fragment_tasks = 7;
uint64 non_fragment_queue_active_cycles = 8;
uint64 reserved_queue_jobs = 9;
uint64 reserved_queue_tasks = 10;


It's quite long. I would like to emit all this data in a trace event, but not sure how.

race([&](GPUMetricsDataSource::TraceContext ctx)
{
    auto packet = ctx.NewTracePacket();
    packet->set_timestamp(perfetto::base::GetBootTimeNs().count());

The Perfetto documentation says you shouldn't send a synthetic trace event. But how else can I send the data above in one event?

Lalit Maganti

unread,
Jun 5, 2025, 6:25:33 PMJun 5
to Jacob Ignatius, Perfetto Development - www.perfetto.dev
What you're doing is the right thing to do (call DataSource::Trace in your data source instance).

> synthetic trace event

Can you point out where you saw this? If you're having your own data source, you're of course free to emit whatever protos you want.

The only problem you're going to have is that trace processor will not have access to your proto so will just drop the data and you won't have any way to visualize it in the UI as a consequence: this is documented at https://perfetto.dev/docs/instrumentation/tracing-sdk#custom-data-sources when we say:

"Unlike track events, when working with custom data sources, you will also need corresponding changes in trace processor to enable importing your data format.".

--
You received this message because you are subscribed to the Google Groups "Perfetto Development - www.perfetto.dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to perfetto-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/perfetto-dev/3b5c61fe-686e-48f2-ac16-cc887925d27bn%40googlegroups.com.
Message has been deleted
Message has been deleted
Message has been deleted

Jacob Ignatius

unread,
Jun 6, 2025, 10:14:29 AMJun 6
to Perfetto Development - www.perfetto.dev
It's really important I do see the data in the UI. Is there any way to do this with mu custom data source? Or use a different approach?

Jacob Ignatius

unread,
Jun 6, 2025, 10:14:29 AMJun 6
to Perfetto Development - www.perfetto.dev
I am now trying a different approach involving a custom track event. So I have defined my new proto message and followed the instructions here: https://perfetto.dev/docs/instrumentation/track-events

Now I'm trying to build Perfetto on a Ubuntu machine for arm64, but it's failing. The protoc is crashing since it isn't built for my platform. How do I get round this problem?
On Thursday, June 5, 2025 at 11:25:33 PM UTC+1 Lalit Maganti wrote:

Jacob Ignatius

unread,
Jun 6, 2025, 10:14:40 AMJun 6
to Perfetto Development - www.perfetto.dev
Thanks for your reply. It's really important that I do see the data in the UI. Any way I can do this?

On Thursday, June 5, 2025 at 11:25:33 PM UTC+1 Lalit Maganti wrote:
Reply all
Reply to author
Forward
0 new messages