···32 });
33}
3435+#[inline(always)]
36+fn ser(block: Vec<u8>) -> Vec<u8> {
37+ let s = block.len();
38+ usize::to_ne_bytes(s).to_vec()
39+}
40+41async fn drive_car(bytes: &[u8]) -> usize {
42+ let mut driver = match Driver::load_car(bytes, ser, 32)
43 .await
44 .unwrap()
45 {
+4-3
examples/read-file/main.rs
···24 let reader = tokio::io::BufReader::new(reader);
2526 let (commit, mut driver) = match DriverBuilder::new()
27- .with_block_processor(|block| block.len().to_ne_bytes().to_vec().into())
28 .load_car(reader)
29 .await?
30 {
31- Driver::Memory(commit, mem_driver) => (commit, mem_driver),
32- Driver::Disk(_) => panic!("this example doesn't handle big CARs"),
033 };
3435 log::info!("got commit: {commit:?}");
···24 let reader = tokio::io::BufReader::new(reader);
2526 let (commit, mut driver) = match DriverBuilder::new()
27+ .with_block_processor(|block| block.len().to_ne_bytes().to_vec())
28 .load_car(reader)
29 .await?
30 {
31+ None => todo!(),
32+ Some(Driver::Memory(commit, mem_driver)) => (commit, mem_driver),
33+ Some(Driver::Disk(_)) => panic!("this example doesn't handle big CARs"),
34 };
3536 log::info!("got commit: {commit:?}");
+6-6
readme.md
···86static GLOBAL: MiMalloc = MiMalloc;
87```
8889-- 450MiB CAR file: `1.1s` (-15%)
90-- 128MiB: `310ms` (-13%)
91-- 5.0MiB: `6.1ms` (-10%)
92-- 279KiB: `160us` (-5%)
93-- 3.4KiB: `5.7us` (-9%)
94-- empty: `660ns` (-7%)
9596processing CARs requires buffering blocks, so it can consume a lot of memory. repo-stream's in-memory driver has minimal memory overhead, but there are two ways to make it work with less mem (you can do either or both!)
97
···86static GLOBAL: MiMalloc = MiMalloc;
87```
8889+- 450MiB CAR file: `1.2s` (-8%)
90+- 128MiB: `300ms` (-14%)
91+- 5.0MiB: `6.0ms` (-12%)
92+- 279KiB: `140us` (-21%)
93+- 3.4KiB: `4.7us` (-10%)
94+- empty: `640ns` (-4%)
9596processing CARs requires buffering blocks, so it can consume a lot of memory. repo-stream's in-memory driver has minimal memory overhead, but there are two ways to make it work with less mem (you can do either or both!)
97