How to masure evaluation time?

Hello there, recently on a pr it was suggested to use lib.something instead of with lib; which would reduce evaluation time since lib was a big attr set, that made me wonder on what else i could do to reduce evaluation time and thus wondering how could i measure and test different evaluations.

Thats why i was wondering how to measure evaluation time and what other techniques you guys applied to reduce evaluation time.

One way to measure eval performance is with NIX_SHOW_STATS=1 env variable, but that wouldn’t tell you much for the difference in cases like using inherit instead of with.

(A bit of self-promotion) Since yesterday nix master branch has support for function call profiler. It should already be quite useful for profiling function calls, but won’t tell you much about thunk evaluation (that is much more costly to implement and I guess would be very hard to interpret without deep knowledge about how the evaluator works under the hood). My flamegraph viewer of choice is speedscope, but there are lots of alternatives.

There’s also —trace-function-calls, but that is superseded by the new profiler.

2 Likes