Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add facilities to produce pprof profiles
This (rather large) commit adds pprof profile generation to lightswitch. They can be dumped to disk and the read with pprof tooling (see test plan) as well as sent to a remote server with a new collector. By default profiles are written to dis as flamegraphs in svg format. Test Plan / Demo ================ build with: `nix develop --command 'cargo build --release'` ``` $ sudo target/release/lightswitch --duration=5 ``` produces a flamegraph in svg format ``` $ sudo target/release/lightswitch --duration=5 --profile-format=pprof ``` produces a pprof file (uncompressed) that can be read with standard tooling ``` $ go tool pprof profile.pb For tag pid used unit task-tgid, also encountered unit(s) task-id File: ruby Build ID: gnu-bae4d9744266cf1f3e27a1ba7512c1c97b5e4a86 lightswitch Type: cpu Time: Jul 23, 2024 at 10:03am (BST) Duration: 5s, Total samples = 1.70s (34.07%) Entering interactive mode (type "help" for commands, "o" for options) (pprof) top For tag pid used unit task-tgid, also encountered unit(s) task-id Showing nodes accounting for 703.70ms, 41.30% of 1703.70ms total Showing top 10 nodes out of 140 flat flat% sum% cum cum% 111.11ms 6.52% 6.52% 148.15ms 8.70% BSD_vfprintf 111.11ms 6.52% 13.04% 259.26ms 15.22% lightswitch::unwind_info::UnwindInfoBuilder::process 111.11ms 6.52% 19.57% 222.22ms 13.04% n_tty_inherit_ops 74.07ms 4.35% 23.91% 111.11ms 6.52% __memcpy_avx_unaligned_erms 74.07ms 4.35% 28.26% 407.41ms 23.91% do_syscall_64 74.07ms 4.35% 32.61% 74.07ms 4.35% queue_work_on 37.04ms 2.17% 34.78% 37.04ms 2.17% __GI___pthread_enable_asynccancel 37.04ms 2.17% 36.96% 444.44ms 26.09% __GI___writev 37.04ms 2.17% 39.13% 37.04ms 2.17% __malloc_usable_size 37.04ms 2.17% 41.30% 37.04ms 2.17% __probestub_page_fault_kernel ``` ``` $ sudo target/release/lightswitch --duration=5 --sender=remote ``` Performs an HTTP POST with the pprof as the body to a hardcoded server URL (this will change in the future).
- Loading branch information