]> git.proxmox.com Git - proxmox-backup.git/commitdiff
image backup: use 4M input buffer
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 17 Jul 2024 13:08:27 +0000 (15:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 19 Jul 2024 08:05:19 +0000 (10:05 +0200)
with the default 8k input buffer size, the client will spend most of the time
polling instead of reading/chunking/uploading.

tested with 16G random data file from tmpfs to fresh datastore backed by tmpfs,
without encryption.

stock:

Time (mean ± σ):     36.064 s ±  0.655 s    [User: 21.079 s, System: 26.415 s]
  Range (min … max):   35.663 s … 36.819 s    3 runs

patched:

 Time (mean ± σ):     23.591 s ±  0.807 s    [User: 16.532 s, System: 18.629 s]
  Range (min … max):   22.663 s … 24.125 s    3 runs

Summary
  patched ran
    1.53 ± 0.06 times faster than stock

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
proxmox-backup-client/src/main.rs

index 6a7d09047c03b2b6f1f5b4c4bca91499b3228f83..5edb2a824ef9aba43eab0dcdb9b0e0f4de1f928d 100644 (file)
@@ -286,8 +286,12 @@ async fn backup_image<P: AsRef<Path>>(
 
     let file = tokio::fs::File::open(path).await?;
 
-    let stream = tokio_util::codec::FramedRead::new(file, tokio_util::codec::BytesCodec::new())
-        .map_err(Error::from);
+    let stream = tokio_util::codec::FramedRead::with_capacity(
+        file,
+        tokio_util::codec::BytesCodec::new(),
+        4 * 1024 * 1024,
+    )
+    .map_err(Error::from);
 
     let stream = FixedChunkStream::new(stream, chunk_size.unwrap_or(4 * 1024 * 1024));