about summary refs log tree commit diff
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2023-11-19T06·24+0000
committeredef <edef@edef.eu>2023-11-19T09·53+0000
commit785ff80c8b8adad22927eee3a0c9c7aaa60072b3 (patch)
treedb718a0ac33086b3edafe8374ef8f5a407d532c3
parent2eaee1d48e59e2a2c75493289e5e09aa14726f17 (diff)
fix(nix-compat/nar/reader): require BufRead r/7034
We rely on being able to make small reads cheaply, so this was already
an implicit practical requirement. Requiring it explicitly removes a
performance footgun, and makes further optimisations possible.

Change-Id: I7f65880a41b1d6b5e6bf2e52dfe47d4c49b34bcd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10088
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
-rw-r--r--tvix/nix-compat/src/nar/reader/mod.rs4
-rw-r--r--tvix/store/src/nar/import.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/tvix/nix-compat/src/nar/reader/mod.rs b/tvix/nix-compat/src/nar/reader/mod.rs
index 09af41866508..4958a67de304 100644
--- a/tvix/nix-compat/src/nar/reader/mod.rs
+++ b/tvix/nix-compat/src/nar/reader/mod.rs
@@ -5,7 +5,7 @@
 //! and transferring store paths between Nix stores.
 
 use std::io::{
-    self,
+    self, BufRead,
     ErrorKind::{InvalidData, UnexpectedEof},
     Read,
 };
@@ -17,7 +17,7 @@ mod read;
 #[cfg(test)]
 mod test;
 
-pub type Reader<'a> = dyn Read + Send + 'a;
+pub type Reader<'a> = dyn BufRead + Send + 'a;
 
 /// Start reading a NAR file from `reader`.
 pub fn open<'a, 'r>(reader: &'a mut Reader<'r>) -> io::Result<Node<'a, 'r>> {
diff --git a/tvix/store/src/nar/import.rs b/tvix/store/src/nar/import.rs
index a9a9cc12d8e1..000fc05663b2 100644
--- a/tvix/store/src/nar/import.rs
+++ b/tvix/store/src/nar/import.rs
@@ -1,5 +1,5 @@
 use std::{
-    io::{self, Read},
+    io::{self, BufRead},
     sync::Arc,
 };
 
@@ -21,7 +21,7 @@ use tvix_castore::{
 /// This function is not async (because the NAR reader is not)
 /// and calls [tokio::task::block_in_place] when interacting with backing
 /// services, so make sure to only call this with spawn_blocking.
-pub fn read_nar<R: Read + Send>(
+pub fn read_nar<R: BufRead + Send>(
     r: &mut R,
     blob_service: Arc<dyn BlobService>,
     directory_service: Arc<dyn DirectoryService>,