mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Documents profiling instructions that I've figured out over the last couple of days. Since Rust 1.79, the standard library is compiled with frame pointers enabled [0]. Grabbing stack-trace information from the frame pointer makes profiling much easier because the data is just there in-line. Using debug information (via `dwarf`) is also possible but requires post-processing of the performance profile with `addr2line` (`perf script` does that automatically). This can take multiple minutes or longer, depending on the sampling frequency of the captured performance data. This makes benchmarking almost infeasible because the feedback loop is simply too long. Using frame pointers is a much nicer experience. The downside is that the application themselves also needs to be compiled with frame pointers. We achieve that by setting the appropriate compiler option in `.cargo/config.toml`. Ubuntu [1], Fedora [2] and Arch [3] also ship all of their code with frame pointers enabled. Also, tech giants such as Google & Meta have been running their systems with frame pointers on-by-default for years [4]. [0]: https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html#frame-pointers-enabled-in-standard-library-builds [1]: https://www.brendangregg.com/blog/2024-03-17/the-return-of-the-frame-pointers.html [2]: https://pagure.io/fesco/issue/2923 [3]: https://gitlab.archlinux.org/archlinux/rfcs/-/merge_requests/26 [4]: https://www.brendangregg.com/blog/2024-03-17/the-return-of-the-frame-pointers.html