From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <c.ebner@proxmox.com>
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 ABAB0BC2FB
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Mar 2024 13:38:41 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id E089EA05A
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Mar 2024 13:37:49 +0100 (CET)
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
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Mar 2024 13:37:48 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B034042936
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Mar 2024 13:37:48 +0100 (CET)
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu, 28 Mar 2024 13:36:59 +0100
Message-Id: <20240328123707.336951-51-c.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20240328123707.336951-1-c.ebner@proxmox.com>
References: <20240328123707.336951-1-c.ebner@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.029 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
 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] [PATCH v3 proxmox-backup 50/58] client: backup writer:
 add injected chunk count to stats
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 28 Mar 2024 12:38:41 -0000

Track the number of injected chunks and show them in the debug output

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 2:
- not present in previous version

 pbs-client/src/backup_writer.rs | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/pbs-client/src/backup_writer.rs b/pbs-client/src/backup_writer.rs
index 032d93da7..828bd7a3e 100644
--- a/pbs-client/src/backup_writer.rs
+++ b/pbs-client/src/backup_writer.rs
@@ -57,6 +57,7 @@ pub struct UploadOptions {
 struct UploadStats {
     chunk_count: usize,
     chunk_reused: usize,
+    chunk_injected: usize,
     size: usize,
     size_reused: usize,
     size_compressed: usize,
@@ -400,6 +401,11 @@ impl BackupWriter {
                 archive,
                 (upload_stats.duration.as_micros()) / (upload_stats.chunk_count as u128)
             );
+            log::debug!(
+                "{}: Injected {} chunks from previous snapshot.",
+                archive,
+                upload_stats.chunk_injected,
+            );
         }
 
         let param = json!({
@@ -646,6 +652,8 @@ impl BackupWriter {
         let total_chunks2 = total_chunks.clone();
         let known_chunk_count = Arc::new(AtomicUsize::new(0));
         let known_chunk_count2 = known_chunk_count.clone();
+        let injected_chunk_count = Arc::new(AtomicUsize::new(0));
+        let injected_chunk_count2 = known_chunk_count.clone();
 
         let stream_len = Arc::new(AtomicUsize::new(0));
         let stream_len2 = stream_len.clone();
@@ -675,7 +683,9 @@ impl BackupWriter {
             )
             .and_then(move |chunk_info| match chunk_info {
                 InjectedChunksInfo::Known(chunks) => {
-                    total_chunks.fetch_add(chunks.len(), Ordering::SeqCst);
+                    let count = chunks.len();
+                    total_chunks.fetch_add(count, Ordering::SeqCst);
+                    injected_chunk_count.fetch_add(count, Ordering::SeqCst);
                     future::ok(MergedChunkInfo::Known(chunks))
                 }
                 InjectedChunksInfo::Raw((offset, data)) => {
@@ -787,6 +797,7 @@ impl BackupWriter {
                 let duration = start_time.elapsed();
                 let chunk_count = total_chunks2.load(Ordering::SeqCst);
                 let chunk_reused = known_chunk_count2.load(Ordering::SeqCst);
+                let chunk_injected = injected_chunk_count2.load(Ordering::SeqCst);
                 let size = stream_len2.load(Ordering::SeqCst);
                 let size_reused = reused_len2.load(Ordering::SeqCst);
                 let size_compressed = compressed_stream_len2.load(Ordering::SeqCst) as usize;
@@ -797,6 +808,7 @@ impl BackupWriter {
                 futures::future::ok(UploadStats {
                     chunk_count,
                     chunk_reused,
+                    chunk_injected,
                     size,
                     size_reused,
                     size_compressed,
-- 
2.39.2