## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# 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`.