Newshot

Nix:使用 eval-profiler

Translation(model translation, not the source's own text)

Nix 2.35.6 Reference Manual

Using the eval-profiler

Nix 求值器支持与 flamegraph.pl 兼容的求值性能分析。分析器会定期对 nix 函数调用栈进行采样。可通过 eval-profiler 设置启用:


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

栈采样频率和输出文件路径可通过 eval-profile-file 和 eval-profiler-frequency 配置。默认情况下,收集到的性能分析数据会保存到当前工作目录下的 nix.profile 文件。

收集到的性能分析数据可直接由 flamegraph.pl 使用:


        $ flamegraph.pl nix.profile > flamegraph.svg
      

性能分析数据中的行信息包含调用点位置以及被调用函数的名称(当可用时)。例如:


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

此处 import primop 在 /nix/store/2q71fdvr4h33g9832hiriwnf20fn630l-source/pkgs/top-level/default.nix:167:5 处被调用。

Only about 667 characters could be extracted — the rest did not come through (common on sites that need scrolling or a login). Read the original for the full piece.

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 ↗