![]() |
Retro Rocket OS
|
This page describes how to enable and use the built-in kernel profiler in Retro Rocket. It is intended for OS developers working on the kernel and low-level subsystems.
Retro Rocket includes a lightweight profiling system based on GCC’s function instrumentation hooks:
When enabled, the compiler injects calls on every function entry and exit. The kernel collects total cycles per function, call counts, and parent to child call relationships.
The output is written in Callgrind format, which can be opened in tools such as KCachegrind or QCachegrind.
Profiling is disabled by default. To enable it, build the kernel with the PROFILE_KERNEL CMake flag:
This will include the profiler subsystem in the kernel and significantly slow down execution (this is expected)
Boot the kernel as usual. Profiling is active immediately.
Press:
This will disable interrupts, freeze profiling data, dump the profile to the first serial port, and resume execution.
Run QEMU with serial output redirected:
After triggering a dump, the file callgrind.out will contain the profile. Running the dump twice in the same session will append both dumps together. Doing so is not recommended, as KCachegrind and similar programs are not designed for this and may crash.
If you need multiple profiles, clear or rename the output file between runs.
Open the output with:
Further documentation on KCachegrind can be found on the official website for the project.