about summary refs log tree commit diff
path: root/tvix/store/src/nar
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2023-11-19T06·56+0000
committeredef <edef@edef.eu>2023-11-19T09·53+0000
commita11abc02e26186b698bfe5ba6271f28e512c6cf6 (patch)
tree4011411150684458dda8026f5282c8e99376e4e1 /tvix/store/src/nar
parent785ff80c8b8adad22927eee3a0c9c7aaa60072b3 (diff)
feat(nix-compat/nar/reader): provide passthrough buffered I/O r/7035
Allow taking advantage of the buffer of the underlying reader to avoid
unnecessary copies of file data.

We can't easily implement the methods of BufRead directly, since we
have some extra I/O to perform in the final consume() invocation.

That could be resolved at the cost of additional bookkeeping, but this
will suffice for now.

Change-Id: I8100cf0abd79e7469670b8596bd989be5db44a91
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10089
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/nar')
-rw-r--r--tvix/store/src/nar/import.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/tvix/store/src/nar/import.rs b/tvix/store/src/nar/import.rs
index 000fc05663b2..e9065a670d21 100644
--- a/tvix/store/src/nar/import.rs
+++ b/tvix/store/src/nar/import.rs
@@ -135,13 +135,13 @@ fn process_file_reader(
 
     // write the blob.
     let mut blob_writer = {
-        let mut dest = SyncIoBridge::new(blob_writer);
-        io::copy(&mut file_reader, &mut dest)?;
+        let mut dst = SyncIoBridge::new(blob_writer);
 
-        dest.shutdown()?;
+        file_reader.copy(&mut dst)?;
+        dst.shutdown()?;
 
-        // return back the blob_reader
-        dest.into_inner()
+        // return back the blob_writer
+        dst.into_inner()
     };
 
     // close the blob_writer, retrieve the digest.