about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-11-23T08·32-0800
committerclbot <clbot@tvl.fyi>2022-12-02T13·32+0000
commit8eb32fb2d79699ffc429f3bd355958da185cb6d9 (patch)
tree073c2a26d317d45a5d35aaf56856c5ecc6f7c998 /tvix/eval/src/vm.rs
parent7ffeb4f7f1657d29df9832460ce6fa33a2184bad (diff)
feat(tvix/eval): crude caching builtins.import r/5366
Before this, tvix was spending most of its time furiously re-parsing
and re-compiling nixpkgs, each time hoping to get a different result...

Change-Id: I1c0cfbf9af622c276275b1f2fb8d4e976f1b5533
Signed-off-by: Adam Joseph <adam@westernsemico.com>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7361
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index f6605940a3..b5f948a96a 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -2,7 +2,7 @@
 //! Tvix bytecode.
 
 use serde_json::json;
-use std::{cmp::Ordering, ops::DerefMut, path::PathBuf, rc::Rc};
+use std::{cmp::Ordering, collections::BTreeMap, ops::DerefMut, path::PathBuf, rc::Rc};
 
 use crate::{
     chunk::Chunk,
@@ -60,6 +60,8 @@ pub struct VM<'o> {
     /// Runtime warnings collected during evaluation.
     warnings: Vec<EvalWarning>,
 
+    pub import_cache: Box<BTreeMap<PathBuf, Value>>,
+
     nix_search_path: NixSearchPath,
 
     observer: &'o mut dyn RuntimeObserver,
@@ -164,6 +166,7 @@ impl<'o> VM<'o> {
             stack: vec![],
             with_stack: vec![],
             warnings: vec![],
+            import_cache: Default::default(),
         }
     }