I cannot get my custom trace category enabled

22 views
Skip to first unread message

Jon Lui

unread,
Mar 26, 2025, 9:13:50 AMMar 26
to Perfetto Development - www.perfetto.dev
I don't know why i cannot get my custom trace to come out. Please tell me if i did some mistake. I ran the initilization and registration. TrackEvent::IsEnabled() returns 0. 
PERFETTO_DEFINE_CATEGORIES(
    perfetto::Category("Encode")
        .SetDescription("Events from encode pipeline")
);

PERFETTO_TRACK_EVENT_STATIC_STORAGE();

perfetto::TracingInitArgs args;
        args.backends |= perfetto::kInProcessBackend;
        args.backends |= perfetto::kSystemBackend;
        perfetto::Tracing::Initialize(args);
        perfetto::TrackEvent::Register();
        printf("jon initialize perfetto\n");
        if (!perfetto::TrackEvent::IsEnabled()) {
            printf("Perfetto TrackEvent is not enabled.\n");
        } else {
            printf("Perfetto TrackEvent is enabled.\n");
        }
At my trace_event, i checked if the category is enabled or not using TRACE_EVENT_CATEGORY_ENABLED("Encode") and it always says that my category is not enabled.. 

My config file

data_sources {
  config {
    name: "track_event"
    track_event_config {
      enabled_categories: "Encode"
      disabled_categories: "*"
    }
  }
} 

Lalit Maganti

unread,
Mar 26, 2025, 9:17:25 AMMar 26
to Jon Lui, Perfetto Development - www.perfetto.dev
How are you collecting the trace? Are you using tracebox? If so are you passing --system-sockets to it?

--
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/253b4f6b-0324-47ea-8cde-3144b0dd8b15n%40googlegroups.com.

Jon Lui

unread,
Mar 26, 2025, 9:22:26 AMMar 26
to Perfetto Development - www.perfetto.dev

i am running it using tools/tmux -c perf.cfg -C out/linux then i wait a while before collecting 3s of my log

Lalit Maganti

unread,
Mar 26, 2025, 9:29:08 AMMar 26
to Jon Lui, Perfetto Development - www.perfetto.dev
Wait is that your full config? You haven't configured a buffer for the data to go into?

Jon Lui

unread,
Mar 26, 2025, 9:37:42 AMMar 26
to Perfetto Development - www.perfetto.dev
buffers {
  size_kb: 1048576
  fill_policy: RING_BUFFER
}
buffers {
  size_kb: 1048576
  fill_policy: RING_BUFFER
}
data_sources {
  config {
    name: "linux.ftrace"
    target_buffer: 0
    ftrace_config {
      drain_period_ms: 5
      ftrace_events: "sched/*"
      # ftrace_events: "gpu_scheduler/*"
      # symbolize_ksyms: true
      # ksyms_mem_policy: KSYMS_RETAIN
      # enable_function_graph: true
      # function_filters: "xe_*"
    }
  }
}
data_sources {
  config {
    name: "linux.process_stats"
    process_stats_config {
      scan_all_processes_on_start: true
      proc_stats_poll_ms: 1000
    }
  }
}
# data_sources {
#   config {
#     name: "gpu.counters.xe"
#     gpu_counter_config {
#       counter_period_ns: 300000
#     }
#   }
# }

data_sources {
  config {
    name: "track_event"
    track_event_config {
      enabled_categories: "Encode"
      # enabled_categories: "gst"
      disabled_categories: "*"
    }
  }
}

# data_sources {
#   config {
#     name: "linux.sys_stats"
#     sys_stats_config {
#       meminfo_period_ms: 1000
#       meminfo_counters: MEMINFO_MEM_TOTAL
#       meminfo_counters: MEMINFO_MEM_FREE
#       meminfo_counters: MEMINFO_MEM_AVAILABLE
#       meminfo_counters: MEMINFO_GPU
#       stat_period_ms: 1000
#       stat_counters: STAT_CPU_TIMES
#       stat_counters: STAT_FORK_COUNT
#     }
#   }
# }

duration_ms: 1000
write_into_file: true
file_write_period_ms: 200
flush_period_ms: 100

Lalit Maganti

unread,
Mar 26, 2025, 9:40:26 AMMar 26
to Jon Lui, Perfetto Development - www.perfetto.dev
```
duration_ms: 1000
write_into_file: true
file_write_period_ms: 200
flush_period_ms: 100
```

The duration_ms is probably your issue. Your trace will likely finish before you even have a chance to log. What happens if you make this longer?



Jon Lui

unread,
Mar 26, 2025, 9:42:45 AMMar 26
to Perfetto Development - www.perfetto.dev
I added the target_buffer field in track_event and now i can see my events. Thanks very much. I tinker this for an hour. This document doesn't mention that a buffer is required https://perfetto.dev/docs/instrumentation/tracing-sdk

Lalit Maganti

unread,
Mar 26, 2025, 9:43:42 AMMar 26
to Jon Lui, Perfetto Development - www.perfetto.dev
target_buffer is not required if you just want to use buffer zero, it's defaulted to zero.

Jon Lui

unread,
Mar 26, 2025, 9:52:04 AMMar 26
to Perfetto Development - www.perfetto.dev
so its possible that the entire buffer was consumed by ftrace? my buffer is rather large.

buffers {
  size_kb: 1048576
  fill_policy: RING_BUFFER
}

Jon Lui

unread,
Mar 26, 2025, 9:55:02 AMMar 26
to Perfetto Development - www.perfetto.dev
Is there a macro that i can use to trace the call stacks and view them in the trace event? Like in this example, the trace event can also record funcB along with funcA.

funcA {
TRACE_EVENT()
   funcB()

Lalit Maganti

unread,
Mar 26, 2025, 9:56:43 AMMar 26
to Jon Lui, Perfetto Development - www.perfetto.dev
No this is fundamental to how Perfetto works: you need to instrument every function you want to see.

Reply all
Reply to author
Forward
0 new messages