feat(tvix/eval): Box Value::Catchable

This is now the only enum variant for Value that is larger than 8
bytes (it's 16 bytes), so boxing it (especially since it's not
perf-critical) allows us to get the Value size down to only 16 bytes!

Change-Id: I98598e2b762944448bef982e8ff7da6d6683c4aa
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10798
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: aspen <root@gws.fyi>
This commit is contained in:
Aspen Smith 2024-02-10 12:39:24 -05:00 committed by clbot
parent dd26177319
commit 7e286aab1a
11 changed files with 45 additions and 40 deletions

View file

@ -84,12 +84,13 @@ pub enum Value {
FinaliseRequest(bool),
#[serde(skip)]
Catchable(CatchableErrorKind),
Catchable(Box<CatchableErrorKind>),
}
impl From<CatchableErrorKind> for Value {
#[inline]
fn from(c: CatchableErrorKind) -> Value {
Value::Catchable(c)
Value::Catchable(Box::new(c))
}
}
@ -97,8 +98,12 @@ impl<V> From<Result<V, CatchableErrorKind>> for Value
where
Value: From<V>,
{
#[inline]
fn from(v: Result<V, CatchableErrorKind>) -> Value {
v.map_or_else(Value::Catchable, |v| v.into())
match v {
Ok(v) => v.into(),
Err(e) => Value::Catchable(Box::new(e)),
}
}
}
@ -776,8 +781,8 @@ impl Value {
b = b.force(&co, span.clone()).await?;
}
let result = match (a, b) {
(Value::Catchable(c), _) => return Ok(Err(c)),
(_, Value::Catchable(c)) => return Ok(Err(c)),
(Value::Catchable(c), _) => return Ok(Err(*c)),
(_, Value::Catchable(c)) => return Ok(Err(*c)),
// same types
(Value::Integer(i1), Value::Integer(i2)) => i1.cmp(&i2),
(Value::Float(f1), Value::Float(f2)) => f1.total_cmp(&f2),