1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

encode black holes as tApp values

checking for isBlackhole in the forceValue hot path is rather more
expensive than necessary, and with a little bit of trickery we can move
such handling into the isApp case. small performance benefit, but under
some circumstances we've seen 2% improvement as well.

〉 nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system'

before:

  Time (mean ± σ):      4.429 s ±  0.002 s    [User: 3.929 s, System: 0.500 s]
  Range (min … max):    4.427 s …  4.433 s    10 runs

after:

  Time (mean ± σ):      4.396 s ±  0.002 s    [User: 3.894 s, System: 0.501 s]
  Range (min … max):    4.393 s …  4.399 s    10 runs
This commit is contained in:
pennae 2023-12-10 08:24:45 +01:00
parent 0218e4e6c3
commit 78353deb02
7 changed files with 93 additions and 32 deletions

View file

@ -4263,6 +4263,29 @@ static RegisterPrimOp primop_splitVersion({
});
static void prim_blackHoleFn(EvalState & state, const PosIdx pos, Value * * args, Value & v)
{
state.error("infinite recursion encountered")
.debugThrow<InfiniteRecursionError>();
}
static PrimOp primop_blackHole = {
.name = "«blackHole»",
.args = {},
.fun = prim_blackHoleFn,
.hideInDiagnostics = true,
};
static Value makeBlackHole()
{
Value v;
v.mkPrimOp(&primop_blackHole);
return v;
}
Value prim_blackHole = makeBlackHole();
/*************************************************************
* Primop registration
*************************************************************/