feat(tvix/eval): crude caching builtins.import

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
This commit is contained in:
Adam Joseph 2022-11-23 00:32:45 -08:00 committed by clbot
parent 7ffeb4f7f1
commit 8eb32fb2d7
2 changed files with 20 additions and 7 deletions

View file

@ -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(),
}
}