Skip to content

Profiling Uhyve

Jonathan edited this page Jun 5, 2025 · 7 revisions

Using perf

> sudo perf record -g -F 12000 target/release/uhyve path/to/my/bin
> sudo perf script -i perf.data > serial.perf

Open serial.perf in profiler.firefox.com.

Keep in mind that both the kernel and Uhyve should be built in release mode.

Valgrind & KCachegrind

  1. Add debug info to the release profile in the Cargo.toml:

    [profile.release]
    debug = true
  2. Execute Uhyve with valgrind (adapt the kernel and the arguments if necessary)

    > valgrind --tool=callgrind  --dump-instr=yes --collect-jumps=yes --simulate-cache=yes target/release/uhyve data/
    x86_64/hello_world
  3. Investigate the run with KCachegrind

    > kcachegrind callgrind.out.123456

    (of course: adapt the filename of the callgrind-file)

Using uftrace and rftrace

A nightly version of the Rust toolchain must be used, as it is required by the rftrace dependency.

  1. Enable the instruments feature in Uhyve. Make sure that your version contains the changes of Pull Request #991.
  2. Build Uhyve using the -Z instrument-mcount flag (RUSTFLAGS="-Z instrument-mcount" cargo build), as suggested by the rftrace documentation.
  3. Install uftrace using a package manager, or compile a release version of uftrace from source.
  4. Try running sudo uftrace record -a ./target/debug/uhyve ./data/x86_64/hello_world

After a trace is complete, you should be able to run commands like uftrace graph or inspect such files with other tools, such as the Chrome trace viewer or Firefox Profiler. The documentation of rftrace mentions additional examples that might be useful to the reader.

Screenshot of uftrace graph with sample output generated from Uhyve in terminal

Clone this wiki locally