Closed KishorBasavaraju-NI closed 3 weeks ago
We use this flow regularly inside Google so this usecase is well supported. There are two specific things you should do (following from the advice in our docs at https://perfetto.dev/docs/concepts/buffers#incremental-state-in-trace-packets):
1) Any data sources which you want to keep for the lifetime of the trace (process name scraping, package list, system info), you should create a separate ring buffer (which is small, maybe a few MB in size) and put target the data souces there.
Quoting from our internal config, we do something like this:
buffers {
size_kb: 512000
fill_policy: RING_BUFFER
}
buffers {
size_kb: 4096
fill_policy: RING_BUFFER
}
buffers {
size_kb: 128
fill_policy: RING_BUFFER
}
data_sources {
config {
name: "linux.process_stats"
target_buffer: 1
process_stats_config {
scan_all_processes_on_start: true
}
}
}
data_sources {
config {
name: "linux.process_stats"
target_buffer: 2
process_stats_config {
quirks: DISABLE_ON_DEMAND
proc_stats_poll_ms: 30000
}
}
}
2) You should enable the incremental state clearing feature of Perfetto to ensure that any incremental state is reemitted. This means adding a section to the config like so:
incremental_state_config {
clear_period_ms: 10000
}
This should fix your problems, let us know if it doesn't work!
In our application, 512 MB of trace data is generated in around 6 mins. We would like to analyze the performance after few hours of application start. So, we are using 512 MB of RingBuffer, thinking that we get the latest 512 MB of trace data (latest 6 mins data) when the application is stopped after few hours. But the problem is, we are not able to load this trace file in perfetto UI. When opened the perfetto file in text editor, we noticed that the metadata like, process id, process name, thread id and thread name maps were also saved in the same buffer and when the buffer is overflowed, the initial meta data got lost.
Is there any easy way to get only latest event traces instead of storing initial trace in memory or file?