about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-02-10T17·21-0500
committerclbot <clbot@tvl.fyi>2024-02-10T20·34+0000
commit5d2ae840f13641a6f699ab77d43e41d98f459053 (patch)
treed0ca56f8fe1469a34ccd1f8f644322623490f496 /tvix/eval/src
parent7b1632ec71cc56dffa6eeca90fdf122331a5065f (diff)
refactor(tvix/eval): Box the inside of Value::Json r/7496
serde_json::Value is pretty large, and is contributing (albeit not
exclusively) to the large size of the Value repr. Putting it in a box
is *especially* cheap (since it's rarely used) and allows us
to (eventually) cut down on the size of Value.

Change-Id: I005a802d8527b639beb4e938e3320b11ffa1ef23
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10795
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: aspen <root@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/value/json.rs2
-rw-r--r--tvix/eval/src/value/mod.rs2
-rw-r--r--tvix/eval/src/vm/generators.rs2
3 files changed, 3 insertions, 3 deletions
diff --git a/tvix/eval/src/value/json.rs b/tvix/eval/src/value/json.rs
index c2f8b2c2b1..5c627540db 100644
--- a/tvix/eval/src/value/json.rs
+++ b/tvix/eval/src/value/json.rs
@@ -111,7 +111,7 @@ impl Value {
     pub(crate) async fn into_json_generator(self, co: GenCo) -> Result<Value, ErrorKind> {
         match self.into_json(&co).await? {
             Err(cek) => Ok(Value::Catchable(cek)),
-            Ok(json) => Ok(Value::Json(json)),
+            Ok(json) => Ok(Value::Json(Box::new(json))),
         }
     }
 }
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index e0c5a2f512..043788da45 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -78,7 +78,7 @@ pub enum Value {
     #[serde(skip)]
     UnresolvedPath(Box<Path>),
     #[serde(skip)]
-    Json(serde_json::Value),
+    Json(Box<serde_json::Value>),
 
     #[serde(skip)]
     FinaliseRequest(bool),
diff --git a/tvix/eval/src/vm/generators.rs b/tvix/eval/src/vm/generators.rs
index e5468fb06d..cffe36e602 100644
--- a/tvix/eval/src/vm/generators.rs
+++ b/tvix/eval/src/vm/generators.rs
@@ -775,7 +775,7 @@ pub(crate) async fn request_to_json(
     value: Value,
 ) -> Result<serde_json::Value, CatchableErrorKind> {
     match co.yield_(VMRequest::ToJson(value)).await {
-        VMResponse::Value(Value::Json(json)) => Ok(json),
+        VMResponse::Value(Value::Json(json)) => Ok(*json),
         VMResponse::Value(Value::Catchable(cek)) => Err(cek),
         msg => panic!(
             "Tvix bug: VM responded with incorrect generator message: {}",