Skip to content

What yen costs

yen is one file of Nix builtins. Its own cost is small next to nixpkgs and the module system, and it stays small as a fleet grows:

  • Each scope computes each aspect ref once, so aspects that read aspects cost linear time, however deep they nest.
  • Sinks are lazy per receiver. A sink that nobody reads costs nothing.
  • Declarations are one lazy index over every file: a lookup walks its path, never all files.
Cost oracle (tests/cost.sh)BoundWithout the memo
30 levels of aspect-ref diamondsunder 200,000 function calls26 million calls at 16 levels
a 150-host fan-inunder 200,000 function calls954,000 calls

A memo is invisible to an eval, so the oracle bounds Nix’s own counters (NIX_SHOW_STATS), not wall time. The engine evaluates 10,000 modules in about 20 s.

Terminal window
nix-instantiate --eval --strict tests -A failed # [ ]: the engine suites
bash tests/cost.sh # PASS aspect-ref-memo, PASS reduction-memo
Contribute Community Sponsor