refactor(tvix/eval): import_cache can be a HashMap

... instead of a BTreeMap, as we do not need ordering guarantees here.
HashMaps are noticeably faster here (especially as we've been sorting
essentially random data!).

Change-Id: Ie92d74286df9f763c04c9b226ef1066ee8484c13
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8014
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
Vincent Ambo 2023-02-02 13:14:42 +03:00 committed by clbot
parent 98ea614c6e
commit 75d1b72b7c

View file

@ -2,7 +2,7 @@
//! Tvix bytecode.
use serde_json::json;
use std::{cmp::Ordering, collections::BTreeMap, ops::DerefMut, path::PathBuf, rc::Rc};
use std::{cmp::Ordering, collections::HashMap, ops::DerefMut, path::PathBuf, rc::Rc};
use crate::{
chunk::Chunk,
@ -113,7 +113,7 @@ pub struct VM<'o> {
/// Import cache, mapping absolute file paths to the value that
/// they compile to. Note that this reuses thunks, too!
// TODO: should probably be based on a file hash
pub import_cache: Box<BTreeMap<PathBuf, Value>>,
pub import_cache: Box<HashMap<PathBuf, Value>>,
/// Parsed Nix search path, which is used to resolve `<...>`
/// references.