From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6EAD674A0C; Wed, 2 Jun 2021 16:38:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 364A1D164; Wed, 2 Jun 2021 16:38:49 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6EA67C951; Wed, 2 Jun 2021 16:38:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4697646709; Wed, 2 Jun 2021 16:38:44 +0200 (CEST) From: Stefan Reiter To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Date: Wed, 2 Jun 2021 16:38:29 +0200 Message-Id: <20210602143833.4423-6-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210602143833.4423-1-s.reiter@proxmox.com> References: <20210602143833.4423-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -1.572 Adjusted score from AWL reputation of From: address ENA_SUBJ_ODD_CASE 3.2 Subject has odd case KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mount.rs, datastore.rs] Subject: [pve-devel] [PATCH proxmox-backup 5/9] replace AsyncIndexReader with SeekableCachedChunkReader X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 14:38:49 -0000 admin/datastore reads linearly only, so no need for cache (capacity of 1 basically means no cache except for the currently active chunk). mount can do random access too, so cache last 8 chunks for possibly a mild performance improvement. Signed-off-by: Stefan Reiter --- src/api2/admin/datastore.rs | 4 ++-- src/bin/proxmox_backup_client/mount.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index e0dfeecc..7b7f3102 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1182,7 +1182,7 @@ pub fn download_file_decoded( manifest.verify_file(&file_name, &csum, size)?; let chunk_reader = LocalChunkReader::new(datastore, None, CryptMode::None); - let reader = AsyncIndexReader::new(index, chunk_reader); + let reader = CachedChunkReader::new(chunk_reader, index, 1).seekable(); Body::wrap_stream(AsyncReaderStream::new(reader) .map_err(move |err| { eprintln!("error during streaming of '{:?}' - {}", path, err); @@ -1197,7 +1197,7 @@ pub fn download_file_decoded( manifest.verify_file(&file_name, &csum, size)?; let chunk_reader = LocalChunkReader::new(datastore, None, CryptMode::None); - let reader = AsyncIndexReader::new(index, chunk_reader); + let reader = CachedChunkReader::new(chunk_reader, index, 1).seekable(); Body::wrap_stream(AsyncReaderStream::with_buffer_size(reader, 4*1024*1024) .map_err(move |err| { eprintln!("error during streaming of '{:?}' - {}", path, err); diff --git a/src/bin/proxmox_backup_client/mount.rs b/src/bin/proxmox_backup_client/mount.rs index f3498e35..d0f04f89 100644 --- a/src/bin/proxmox_backup_client/mount.rs +++ b/src/bin/proxmox_backup_client/mount.rs @@ -25,7 +25,7 @@ use proxmox_backup::backup::{ BackupDir, BackupGroup, BufferedDynamicReader, - AsyncIndexReader, + CachedChunkReader, }; use proxmox_backup::client::*; @@ -281,7 +281,7 @@ async fn mount_do(param: Value, pipe: Option) -> Result { let index = client.download_fixed_index(&manifest, &server_archive_name).await?; let size = index.index_bytes(); let chunk_reader = RemoteChunkReader::new(client.clone(), crypt_config, file_info.chunk_crypt_mode(), HashMap::new()); - let reader = AsyncIndexReader::new(index, chunk_reader); + let reader = CachedChunkReader::new(chunk_reader, index, 8).seekable(); let name = &format!("{}:{}/{}", repo.to_string(), path, archive_name); let name_escaped = tools::systemd::escape_unit(name, false); -- 2.30.2