Jump to content

Nix Profiling

From justus.pw Wiki

Nix-darwin

First, run the following to get a flamegraph:

# This assumes that you've named your nix-darwin configuration
# after your hostname
nix eval --option eval-profiler flamegraph .#darwinConfigurations.$(hostname).system

You should end up with a file called nix.profile:

$ file nix.profile nix.profile: Unicode text, UTF-8 text, with very long lines (1339

Make flamegraph

This zoomed out screenshot of nix.svg shows what kind of image you should expect to come out of the flamegraph tool for a nix eval run on nix-darwin.

Use the flamegraph package to render this nix.profile file to a SVG image:

$ flamegraph < nix.profile > nix.svg

On my system, this creates a 3.5 MiB SVG file.