Newshot

Nix: Using the eval-profiler

Original text(via Lobsters)

Nix 2.35.6 Reference Manual

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/2q71fdvr4h33g9832hiriwnf20fn630l-source/pkgs/top-level/default.nix:167:5:primop import
      

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

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Lobsters
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗