Perfetto is an open-source system profiler, app tracer, and trace analyzer for Linux, Android & Chrome platforms, and user-space apps. The program can already visualize CPU and memory usage, as well as power consumption. GPU support is more limited with the program only capable of sampling the GPU frequency when the driver outputs that information via ftrace.
When Perfetto is also extendable thanks to a Tracing C++ SDK that “allows userspace applications to emit trace events and add more app-specific context to a Perfetto trace”. Collabora made use of the tracing SDK to add support for Mali Midgard GPU performance profiling in gfx-pps project using the Mali GPU hardware counters exposed via Panfrost open-source Mali GPU driver.
After following the installation instructions, you’ll be able to run the following executables for tracing and profiling:
traced_probesOS probes service.
perfettocommand-line tool for recording traces.
producer-gpuproviding the Panfrost data source.
gpu.cfgconfig file to feed as input to Perfetto describing what to trace, and found in gfx-pps/scripts directory.
Run the following command to quickly get started
perfetto --txt -c gpu.cfg -o trace
Run whatever GPU workload you’d like to profile, and once tracing is complete, you can open
trace file with ui.perfetto.dev in Chrome Browser (I first tried in Firefox and it won’t load).
The screenshot above shows some of the GPU parameters including CPU/GPU balancing (not make sure the CPU is not the bottleneck), Vertex/Fragment balancing, and Tripipe (Arithmetic/Load-Store/Texture) balancing using a trace of WebGL Aquarium taken on a Rockchip RK3399 SoC equipped with a Mali-860MP4 Midgard GPU.
The gfx-pps project is under active development on FreeDesktop’s GitLab and licensed under an MIT license. You’ll find the Panfrost data source in gfx-pps/src/gpu/panfrost/gpu_ds.h file, and the implementation of more GPU data sources is planned.
More details about gfx-pps project can be found on Collabora blog.