about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorConnor Brewster <cbrewster@hey.com>2024-05-06T15·53-0500
committerclbot <clbot@tvl.fyi>2024-05-06T16·05+0000
commitda9bc274f3a07a461b279b18c6b650b0a2808c39 (patch)
treeec027f4e2b643ff0a95014b57f29327826291092 /tvix
parent01a4a2399c2455b672051c1a005dabaf2971025d (diff)
refactor(tvix): remove usage of async-recursion r/8082
Rust 1.77 supports async recursion as long as there is some form of
indirection (ie. `Box::pin`). This removes the need to use the
async-recursion crate.

Change-Id: Ic9613ab7f32016f0103032a861edff92e2fb8b41
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11596
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/Cargo.lock13
-rw-r--r--tvix/Cargo.nix37
-rw-r--r--tvix/crate-hashes.json4
-rw-r--r--tvix/glue/Cargo.toml1
-rw-r--r--tvix/glue/src/tvix_store_io.rs2
-rw-r--r--tvix/store/Cargo.toml1
-rw-r--r--tvix/store/src/nar/import.rs15
-rw-r--r--tvix/store/src/nar/renderer.rs14
8 files changed, 19 insertions, 68 deletions
diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock
index 0efea7a021..8385528e8f 100644
--- a/tvix/Cargo.lock
+++ b/tvix/Cargo.lock
@@ -207,17 +207,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "async-recursion"
-version = "1.0.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.48",
-]
-
-[[package]]
 name = "async-signal"
 version = "0.2.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4387,7 +4376,6 @@ name = "tvix-glue"
 version = "0.1.0"
 dependencies = [
  "async-compression",
- "async-recursion",
  "bstr",
  "bytes",
  "criterion",
@@ -4438,7 +4426,6 @@ dependencies = [
  "anyhow",
  "async-compression",
  "async-process",
- "async-recursion",
  "async-stream",
  "bigtable_rs",
  "blake3",
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index 93fbbb2e09..0efb86c66d 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -719,35 +719,6 @@ rec {
         ];
 
       };
-      "async-recursion" = rec {
-        crateName = "async-recursion";
-        version = "1.0.5";
-        edition = "2018";
-        sha256 = "1l2vlgyaa9a2dd0y1vbqyppzsvpdr1y4rar4gn1qi68pl5dmmmaz";
-        procMacro = true;
-        authors = [
-          "Robert Usher <266585+dcchut@users.noreply.github.com>"
-        ];
-        dependencies = [
-          {
-            name = "proc-macro2";
-            packageId = "proc-macro2";
-            usesDefaultFeatures = false;
-          }
-          {
-            name = "quote";
-            packageId = "quote";
-            usesDefaultFeatures = false;
-          }
-          {
-            name = "syn";
-            packageId = "syn 2.0.48";
-            usesDefaultFeatures = false;
-            features = [ "full" "parsing" "printing" "proc-macro" "clone-impls" ];
-          }
-        ];
-
-      };
       "async-signal" = rec {
         crateName = "async-signal";
         version = "0.2.5";
@@ -14099,10 +14070,6 @@ rec {
             features = [ "tokio" "gzip" "bzip2" "xz" ];
           }
           {
-            name = "async-recursion";
-            packageId = "async-recursion";
-          }
-          {
             name = "bstr";
             packageId = "bstr";
           }
@@ -14301,10 +14268,6 @@ rec {
             features = [ "tokio" "bzip2" "gzip" "xz" "zstd" ];
           }
           {
-            name = "async-recursion";
-            packageId = "async-recursion";
-          }
-          {
             name = "async-stream";
             packageId = "async-stream";
           }
diff --git a/tvix/crate-hashes.json b/tvix/crate-hashes.json
index 2c1e740cb9..ca45e43176 100644
--- a/tvix/crate-hashes.json
+++ b/tvix/crate-hashes.json
@@ -1,4 +1,4 @@
 {
-  "git+https://github.com/flokli/bigtable_rs?rev=0af404741dfc40eb9fa99cf4d4140a09c5c20df7#0.2.9": "1njjam1lx2xlnm7a41lga8601vmjgqz0fvc77x24gd04pc7avxll",
-  "git+https://github.com/tvlfyi/wu-manber.git#wu-manber@0.1.0": "1zhk83lbq99xzyjwphv2qrb8f8qgfqwa5bbbvyzm0z0bljsjv0pd"
+  "bigtable_rs 0.2.9 (git+https://github.com/flokli/bigtable_rs?rev=0af404741dfc40eb9fa99cf4d4140a09c5c20df7#0af404741dfc40eb9fa99cf4d4140a09c5c20df7)": "1njjam1lx2xlnm7a41lga8601vmjgqz0fvc77x24gd04pc7avxll",
+  "wu-manber 0.1.0 (git+https://github.com/tvlfyi/wu-manber.git#0d5b22bea136659f7de60b102a7030e0daaa503d)": "1zhk83lbq99xzyjwphv2qrb8f8qgfqwa5bbbvyzm0z0bljsjv0pd"
 }
\ No newline at end of file
diff --git a/tvix/glue/Cargo.toml b/tvix/glue/Cargo.toml
index 6d7f2e3f02..0afdefeaaa 100644
--- a/tvix/glue/Cargo.toml
+++ b/tvix/glue/Cargo.toml
@@ -5,7 +5,6 @@ edition = "2021"
 
 [dependencies]
 async-compression = { version = "0.4.9", features = ["tokio", "gzip", "bzip2", "xz"]}
-async-recursion = "1.0.5"
 bstr = "1.6.0"
 bytes = "1.4.0"
 data-encoding = "2.3.3"
diff --git a/tvix/glue/src/tvix_store_io.rs b/tvix/glue/src/tvix_store_io.rs
index 7daefffe82..7478fac9d2 100644
--- a/tvix/glue/src/tvix_store_io.rs
+++ b/tvix/glue/src/tvix_store_io.rs
@@ -1,6 +1,5 @@
 //! This module provides an implementation of EvalIO talking to tvix-store.
 
-use async_recursion::async_recursion;
 use bytes::Bytes;
 use futures::{StreamExt, TryStreamExt};
 use nix_compat::nixhash::NixHash;
@@ -92,7 +91,6 @@ impl TvixStoreIO {
     ///
     /// In case there is no PathInfo yet, this means we need to build it
     /// (which currently is stubbed out still).
-    #[async_recursion(?Send)]
     #[instrument(skip(self, store_path), fields(store_path=%store_path), ret(level = Level::TRACE), err)]
     async fn store_path_to_node(
         &self,
diff --git a/tvix/store/Cargo.toml b/tvix/store/Cargo.toml
index 7034a95f38..f82cdef300 100644
--- a/tvix/store/Cargo.toml
+++ b/tvix/store/Cargo.toml
@@ -40,7 +40,6 @@ tracing-subscriber = { version = "0.3.16", features = ["env-filter", "json"] }
 tvix-castore = { path = "../castore" }
 url = "2.4.0"
 walkdir = "2.4.0"
-async-recursion = "1.0.5"
 reqwest = { version = "0.11.22", features = ["rustls-tls-native-roots", "stream"], default-features = false }
 
 [dependencies.tonic-reflection]
diff --git a/tvix/store/src/nar/import.rs b/tvix/store/src/nar/import.rs
index bfb65629e6..cc62c1a4e9 100644
--- a/tvix/store/src/nar/import.rs
+++ b/tvix/store/src/nar/import.rs
@@ -1,4 +1,3 @@
-use async_recursion::async_recursion;
 use nix_compat::nar::reader::r#async as nar_reader;
 use tokio::{io::AsyncBufRead, sync::mpsc, try_join};
 use tvix_castore::{
@@ -54,10 +53,9 @@ where
     Ok(node.rename("".into()))
 }
 
-#[async_recursion]
-async fn produce_nar_inner<'a: 'async_recursion, 'r: 'async_recursion, BS>(
+async fn produce_nar_inner<BS>(
     blob_service: BS,
-    node: nar_reader::Node<'a, 'r>,
+    node: nar_reader::Node<'_, '_>,
     path: PathBuf,
     tx: mpsc::Sender<Result<IngestionEntry, Error>>,
 ) -> Result<IngestionEntry, Error>
@@ -93,8 +91,13 @@ where
                 path.try_push(&entry.name)
                     .expect("Tvix bug: failed to join name");
 
-                let entry =
-                    produce_nar_inner(blob_service.clone(), entry.node, path, tx.clone()).await?;
+                let entry = Box::pin(produce_nar_inner(
+                    blob_service.clone(),
+                    entry.node,
+                    path,
+                    tx.clone(),
+                ))
+                .await?;
 
                 tx.send(Ok(entry)).await.map_err(|e| {
                     Error::IO(std::io::Error::new(std::io::ErrorKind::BrokenPipe, e))
diff --git a/tvix/store/src/nar/renderer.rs b/tvix/store/src/nar/renderer.rs
index 0816b8e973..3b39f700bd 100644
--- a/tvix/store/src/nar/renderer.rs
+++ b/tvix/store/src/nar/renderer.rs
@@ -1,7 +1,6 @@
 use crate::utils::AsyncIoBridge;
 
 use super::RenderError;
-use async_recursion::async_recursion;
 use count_write::CountWrite;
 use nix_compat::nar::writer::r#async as nar_writer;
 use sha2::{Digest, Sha256};
@@ -72,9 +71,8 @@ where
 
 /// Process an intermediate node in the structure.
 /// This consumes the node.
-#[async_recursion]
 async fn walk_node<BS, DS>(
-    nar_node: nar_writer::Node<'async_recursion, '_>,
+    nar_node: nar_writer::Node<'_, '_>,
     proto_node: &castorepb::node::Node,
     blob_service: BS,
     directory_service: DS,
@@ -164,9 +162,13 @@ where
                             .await
                             .map_err(RenderError::NARWriterError)?;
 
-                        (blob_service, directory_service) =
-                            walk_node(child_node, &proto_node, blob_service, directory_service)
-                                .await?;
+                        (blob_service, directory_service) = Box::pin(walk_node(
+                            child_node,
+                            &proto_node,
+                            blob_service,
+                            directory_service,
+                        ))
+                        .await?;
                     }
 
                     // close the directory