about summary refs log tree commit diff
path: root/tvix/eval/docs
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2023-08-23T13·06+0200
committersterni <sternenseemann@systemli.org>2023-11-24T23·36+0000
commitc5961e77749d1d002a5e747468b87c34a32821f3 (patch)
treebe912a20603afa28a731a3e2506d3d74c0596350 /tvix/eval/docs
parent6b685ec4a562693f56dee27624074b7cc38e70c8 (diff)
docs(tvix/eval): optimization potential for inherit (from) exprs r/7052
Change-Id: Ibddaa111a5b7a86c42dbe153ae8e53f9a5601a54
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10112
Tested-by: BuildkiteCI
Reviewed-by: Adam Joseph <adam@westernsemico.com>
Diffstat (limited to 'tvix/eval/docs')
-rw-r--r--tvix/eval/docs/known-optimisation-potential.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/tvix/eval/docs/known-optimisation-potential.md b/tvix/eval/docs/known-optimisation-potential.md
index e2e0497aee..951771e739 100644
--- a/tvix/eval/docs/known-optimisation-potential.md
+++ b/tvix/eval/docs/known-optimisation-potential.md
@@ -138,3 +138,22 @@ optimisations, but note the most important ones here.
   determining if finalisation is necessary or not. This wouldn't be necessary
   if `OpFinalise` would just noop on any values that don't need to be finalised
   (anymore).
+
+* Phantom binding for from expression of inherits [easy]
+
+  The from expression of an inherit is reevaluated for each inherit. This can
+  be demonstrated using the following Nix expression which, counter-intuitively,
+  will print “plonk” twice.
+
+  ```nix
+  let
+    inherit (builtins.trace "plonk" { a = null; b = null; }) a b;
+  in
+  builtins.seq a (builtins.seq b null)
+  ```
+
+  In most Nix code, the from expression is just an identifier, so it is not
+  terribly inefficient, but in some cases a more expensive expression may
+  be used. We should create a phantom binding for the from expression that
+  is reused in the inherits, so only a single thunk is created for the from
+  expression.