perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

How to add event chains and change the hierarchical relationship of tracks in Linux trace?

Open ManiacLook opened this issue 1 year ago • 2 comments

Hello. I used the following trace configuration to obtain the trace data of the Linux system, and obtained the result shown in the following figure. Now I have two ideas: (1) I want to change the displayed hierarchical structure, such as placing all tracks under a new track. (2) I want to add arrows to some trace events(slices) to indicate the event chain. May I ask if it is possible to achieve? Thank you.

Image

# shared by the two data sources below.
buffers {
  size_kb: 32768
  fill_policy: DISCARD
}

# Ftrace data from the kernel, mainly the process scheduling events.
data_sources {
  config {
    name: "linux.ftrace"
    target_buffer: 0
    ftrace_config {
      ftrace_events: "sched_switch"
      ftrace_events: "sched_waking"
      ftrace_events: "sched_wakeup_new"

      ftrace_events: "task_newtask"
      ftrace_events: "task_rename"

      ftrace_events: "sched_process_exec"
      ftrace_events: "sched_process_exit"
      ftrace_events: "sched_process_fork"
      ftrace_events: "sched_process_free"
      ftrace_events: "sched_process_hang"
      ftrace_events: "sched_process_wait"
    }
  }
}

# Resolve process commandlines and parent/child relationships, to better
# interpret the ftrace events, which are in terms of pids.
data_sources {
  config {
    name: "linux.process_stats"
    target_buffer: 0
  }
}

# 20s trace, but can be stopped prematurely.
duration_ms: 20000```

ManiacLook avatar Apr 25 '25 08:04 ManiacLook

  1. It was recently made possible in a custom workspace! After you create a new workspace and move tracks of interest inside, click on the 3 dot menu next to the workspace name and choose Create new group track. You can drag and drop the tracks inside it.
  2. It is not easily doable. Doing so would require quite a bit of plumbing through Trace Processor, SQL and the UI.

aMayzner avatar Apr 25 '25 10:04 aMayzner

Regarding 2. - We are aware that it would be a very nice feature and @stevegolton will be working at some point on implementing this (both in debug tracks and in plugins)

aMayzner avatar Apr 25 '25 11:04 aMayzner