https://github.com/crabdancing/nix-flamegraph
Various primitive scripts cobbled together to produce an easy flamegraph of nix eval
https://github.com/crabdancing/nix-flamegraph
benchmark flamegraph nix nix-flake nixos profiling
Last synced: 9 months ago
JSON representation
Various primitive scripts cobbled together to produce an easy flamegraph of nix eval
- Host: GitHub
- URL: https://github.com/crabdancing/nix-flamegraph
- Owner: crabdancing
- License: wtfpl
- Created: 2024-12-04T09:05:29.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-04T22:04:34.000Z (about 1 year ago)
- Last Synced: 2025-04-13T03:17:42.386Z (11 months ago)
- Topics: benchmark, flamegraph, nix, nix-flake, nixos, profiling
- Language: Nix
- Homepage:
- Size: 9.77 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Semi-usable flamegraph generation for troubleshooting just _why_ your Nix code is so damn slow. This mostly just shows a useful visualization of the call stack, so that you can get an impression of which function is being called recursively five thousand times. :P
# Usage
Help page:
```
nix run github:crabdancing/nix-flamegraph -- --help
```
Process a flake (e.g.):
```
nix run github:crabdancing/nix-flamegraph -- -t /etc/nixos
```
You just point it at a target, and it _hopefully_ prints out the path to an SVG. Internals are very jank. Results may vary.
Note that it prints status info via STDERR, and the actual path via STDOUT. Therefore, it should be easy to extract the path for machine usage if desired. Alternatively, look at the `-o` flag for telling the script to dump your `SVG` to a given path. Note that it will error if path already exists with exit code 5.
# Credits
Internal script is mostly based on posts from [here](https://discourse.nixos.org/t/nix-flamegraph-or-profiling-tool/33333/11) cobbled together.
Yoinked `stack-collapse.py` from [here](https://raw.githubusercontent.com/NixOS/nix/master/contrib/stack-collapse.py), and made slight alterations (to pin Python version against flake deps).
# License
This is basically just a bunch of templates & scripts cobbled together. The parts I contributed are too trivial to really be worthy of anything other than public domain. So, um, do whatever you want.