This repo contains a server, cli and (super basic) UI to store/retrieve profiler data in an efficient manner. There are also a couple of cool DB functions that leverage the properties of the schema.
The main purpose of this repo is to share ideas. I'll link some slides here that explain this more, but TL;DR you can do cool stuff if you represent profiler data in a DAG (which it is) so this does that.
The cli stores/uploads profiler data to postgres, via the server. The cli profiles a provided locally running pid (via libbpf), symbolizes it (via blazesym) and posts it to the server. The interesting part of the server is more/less this. The CLI is all kinda interesting, but also short. There's also a couple of cool DB functions here.
The UI (templated html web page which GET's some json from the server) shows these stored profiles, along with the capacity savings the storage approach used by this repo uses.
The cli and server are buildable via cargo build --release
.
Here's a screenshot of the UI:
The easiest way is to use something like gentoo or arch to have the latest-and-greatest kernel and everything else running locally. Ignoring the incredibly important detail of kernel version, the dependencies are all in .devcontainer, in either Dockerfile.db or Dockerfile.
Note -- this does not work yet, codespaces are running an older kernel than this needs, kernel req TBD (I think 5.19 may work but need to confirm).
I will upload data from a gentoo machine to enable this to be a read-only live-demo with real-yet-contrived data until codespaces are running a new-enough kernel to enable profiling via libbpf in them.
- Fork it via:
- On your fork, open a code-space of it in your browser via:
- Build the server and cli by entering the following into the terminal of your code space as the following image shows:
cargo build --release
- Start the server via the following command, and open a new terminal via the indicated
+
button:
./target/release/server
- In this new tab, built and run a binary to test via the following command (or just use htop/whatever and get it's pid, etc.):
cd demo && make && ./demo
-
Copy the numbers printed (the demo binary's PID) and open a new terminal via the
+
button indicated: -
In this new terminal, profile the demo binary and send data to the server via the following command, then click the ports button:
./target/release/cli --version one-or-whatever --binary demo-or-whatever --pid 32651
- https://github.com/hodgesds/bpftune -- profiler to generate audio from stack snapshots so you can hear the sounds of all your polling and locks.
- https://github.com/libbpf/libbpf-rs -- enable using bpf profilers via rust easy because rust makes some things easier.
- https://github.com/libbpf/blazesym -- deal with the hard problem of symbolization for me because it's really hard. Also in rust.
- lots of random copy pastes from the internet that I don't recall atm lol.