1# Heap profiling 2 3Cloud Hypervisor supports generating a profile using 4[dhat](https://docs.rs/dhat/latest/dhat/) of the heap allocations made during 5the runtime of the process. 6 7## Building a suitable binary 8 9This adds the symbol information to the release binary but does not otherwise 10affect the performance. 11 12``` 13$ cargo build --profile profiling --features "dhat-heap" 14``` 15 16## Generating output 17 18Cloud Hypervisor can then be run as usual. However it is necessary to run with `--seccomp false` as the profiling requires extra syscalls. 19 20``` 21$ target/profiling/cloud-hypervisor \ 22 --kernel ~/src/linux/vmlinux \ 23 --pmem file=~/workloads/focal.raw \ 24 --cpus boot=1 --memory size=1G \ 25 --cmdline "root=/dev/pmem0p1 console=ttyS0" \ 26 --serial tty --console off \ 27 --api-socket /tmp/api1 \ 28 --seccomp false 29``` 30 31When the VMM exits a message like the following will be shown: 32 33``` 34dhat: Total: 384,582 bytes in 3,512 blocks 35dhat: At t-gmax: 133,885 bytes in 379 blocks 36dhat: At t-end: 12,160 bytes in 20 blocks 37dhat: The data has been saved to dhat-heap.json, and is viewable with dhat/dh_view.html 38``` 39 40The JSON output can then be uploaded to [the dh_view tool](https://nnethercote.github.io/dh_view/dh_view.html) for analysis. 41 42