From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 77A911FF185 for ; Mon, 7 Jul 2025 15:26:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3FF1E33C00; Mon, 7 Jul 2025 15:27:10 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 7 Jul 2025 15:27:05 +0200 Message-Id: <20250707132706.2854973-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250707132706.2854973-1-d.csapak@proxmox.com> References: <20250707132706.2854973-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.021 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [RFC PATCH proxmox-backup 2/3] verify: move chunk loading into parallel handler X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" This way, the chunks will be loaded in parallel in addition to being checked in parallel. Depending on the underlying storage, this can speed up reading chunks from disk, especially when the underlying storage is IO depth dependent, and the CPU is faster than the storage. In my local tests I measured the following speed difference: verified a single snapshot with ~64 GiB (4x the RAM size) with 12 cores current: ~550MiB/s this patch: ~950MiB/s Obviously it increased the IO and CPU load in line with the throughput. Signed-off-by: Dominik Csapak --- src/backup/verify.rs | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/backup/verify.rs b/src/backup/verify.rs index ba4ca4d2f..83dd0d9a3 100644 --- a/src/backup/verify.rs +++ b/src/backup/verify.rs @@ -1,6 +1,6 @@ use pbs_config::BackupLockGuard; use std::collections::HashSet; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; use std::time::Instant; @@ -17,7 +17,7 @@ use pbs_api_types::{ use pbs_datastore::backup_info::{BackupDir, BackupGroup, BackupInfo}; use pbs_datastore::index::IndexFile; use pbs_datastore::manifest::{BackupManifest, FileInfo}; -use pbs_datastore::{DataBlob, DataStore, StoreProgress}; +use pbs_datastore::{DataStore, StoreProgress}; use crate::tools::parallel_handler::ParallelHandler; @@ -106,16 +106,32 @@ fn verify_index_chunks( let start_time = Instant::now(); - let mut read_bytes = 0; - let mut decoded_bytes = 0; + let read_bytes = Arc::new(AtomicU64::new(0)); + let decoded_bytes = Arc::new(AtomicU64::new(0)); let decoder_pool = ParallelHandler::new("verify chunk decoder", 4, { let datastore = Arc::clone(&verify_worker.datastore); let corrupt_chunks = Arc::clone(&verify_worker.corrupt_chunks); let verified_chunks = Arc::clone(&verify_worker.verified_chunks); let errors = Arc::clone(&errors); + let read_bytes = Arc::clone(&read_bytes); + let decoded_bytes = Arc::clone(&decoded_bytes); - move |(chunk, digest, size): (DataBlob, [u8; 32], u64)| { + move |(digest, size): ([u8; 32], u64)| { + let chunk = match datastore.load_chunk(&digest) { + Err(err) => { + corrupt_chunks.lock().unwrap().insert(digest); + error!("can't verify chunk, load failed - {err}"); + errors.fetch_add(1, Ordering::SeqCst); + rename_corrupted_chunk(datastore.clone(), &digest); + return Ok(()); + } + Ok(chunk) => { + read_bytes.fetch_add(chunk.raw_size(), Ordering::SeqCst); + decoded_bytes.fetch_add(size, Ordering::SeqCst); + chunk + } + }; let chunk_crypt_mode = match chunk.crypt_mode() { Err(err) => { corrupt_chunks.lock().unwrap().insert(digest); @@ -193,30 +209,16 @@ fn verify_index_chunks( continue; // already verified or marked corrupt } - match verify_worker.datastore.load_chunk(&info.digest) { - Err(err) => { - verify_worker - .corrupt_chunks - .lock() - .unwrap() - .insert(info.digest); - error!("can't verify chunk, load failed - {err}"); - errors.fetch_add(1, Ordering::SeqCst); - rename_corrupted_chunk(verify_worker.datastore.clone(), &info.digest); - } - Ok(chunk) => { - let size = info.size(); - read_bytes += chunk.raw_size(); - decoder_pool.send((chunk, info.digest, size))?; - decoded_bytes += size; - } - } + decoder_pool.send((info.digest, info.size()))?; } decoder_pool.complete()?; let elapsed = start_time.elapsed().as_secs_f64(); + let read_bytes = read_bytes.load(Ordering::SeqCst); + let decoded_bytes = decoded_bytes.load(Ordering::SeqCst); + let read_bytes_mib = (read_bytes as f64) / (1024.0 * 1024.0); let decoded_bytes_mib = (decoded_bytes as f64) / (1024.0 * 1024.0); -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel