1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00
nix/doc/manual/source/advanced-topics/eval-profiler.md
2025-05-21 22:16:31 +00:00

1.3 KiB

Using the eval-profiler

Nix evaluator supports evaluation profiling compatible with flamegraph.pl. The profiler samples the nix function call stack at regular intervals. It can be enabled with the eval-profiler setting:

$ nix-instantiate "<nixpkgs>" -A hello --eval-profiler flamegraph

Stack sampling frequency and the output file path can be configured with eval-profile-file and eval-profiler-frequency. By default the collected profile is saved to nix.profile file in the current working directory.

The collected profile can be directly consumed by flamegraph.pl:

$ flamegraph.pl nix.profile > flamegraph.svg

The line information in the profile contains the location of the call site position and the name of the function being called (when available). For example:

/nix/store/x9wnkly3k1gkq580m90jjn32q9f05q2v-source/pkgs/top-level/default.nix:167:5:primop import

Here import primop is called at /nix/store/x9wnkly3k1gkq580m90jjn32q9f05q2v-source/pkgs/top-level/default.nix:167:5.