refactor(tvix/eval): wrap NixList in Rc

The size of a `Vector<Value>` is 64 *bytes*, which is quite large, and
it bloated the entire Value type to this size.

This change adds an indirection for the inner vector through Rc.
Initially I tried to use a Box, but this breaks pointer equality
guarantees for the Vector when it is small enough to be inlined.

This reduces the size of Value from 64 to 32 bytes.

Change-Id: Ic3211e861b1966c78b2c3d536ba291fea92647fd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8150
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2023-02-27 10:22:38 +03:00 committed by tazjin
parent 83b2290e1b
commit 4bbfeaf1cb
2 changed files with 16 additions and 14 deletions

View file

@ -826,9 +826,9 @@ mod pure_builtins {
#[builtin("sort")]
async fn builtin_sort(co: GenCo, comparator: Value, list: Value) -> Result<Value, ErrorKind> {
let mut list = list.to_list()?;
list.sort_by(&co, comparator).await?;
Ok(Value::List(list))
let list = list.to_list()?;
let sorted = list.sort_by(&co, comparator).await?;
Ok(Value::List(sorted))
}
#[builtin("splitVersion")]