mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02: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:
parent
0218e4e6c3
commit
78353deb02
7 changed files with 93 additions and 32 deletions
|
@ -104,11 +104,16 @@ void EvalState::forceValue(Value & v, Callable getPos)
|
|||
}
|
||||
}
|
||||
else if (v.isApp()) {
|
||||
PosIdx pos = getPos();
|
||||
callFunction(*v.app.left, *v.app.right, v, pos);
|
||||
try {
|
||||
callFunction(*v.app.left, *v.app.right, v, noPos);
|
||||
} catch (InfiniteRecursionError & e) {
|
||||
// only one black hole can *throw* in any given eval stack so we need not
|
||||
// check whether the position is set already.
|
||||
if (v.isBlackhole())
|
||||
e.err.errPos = positions[getPos()];
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else if (v.isBlackhole())
|
||||
error("infinite recursion encountered").atPos(getPos()).template debugThrow<EvalError>();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue