[pbs-devel] [PATCH proxmox-backup 2/2] garbage collection: track chunk cache stats and show in task log

Christian Ebner c.ebner at proxmox.com
Fri May 16 10:58:36 CEST 2025


Count the chunk cache hits and misses and display the resulting
values in the garbage collection task log summary.

This allows to investigate possible issues and tune cache capacity,
also by being able to compare to other values in the summary such
as the on disk chunk count.

Exemplary output
```
2025-05-16T10:41:29+02:00: Chunk cache: hits 38118, misses 10017
2025-05-16T10:41:29+02:00: Removed garbage: 3.384 GiB
2025-05-16T10:41:29+02:00: Removed chunks: 2835
2025-05-16T10:41:29+02:00: Original data usage: 155.165 GiB
2025-05-16T10:41:29+02:00: On-Disk usage: 7.312 GiB (4.71%)
2025-05-16T10:41:29+02:00: On-Disk chunks: 10017
2025-05-16T10:41:29+02:00: Deduplication factor: 21.22
2025-05-16T10:41:29+02:00: Average chunk size: 765.438 KiB
```

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-datastore/src/datastore.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index cbf78ecb6..479b76cd8 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1086,8 +1086,10 @@ impl DataStore {
 
             // Avoid multiple expensive atime updates by utimensat
             if chunk_lru_cache.insert(*digest, ()) {
+                status.cache_hits += 1;
                 continue;
             }
+            status.cache_misses += 1;
 
             if !self.inner.chunk_store.cond_touch_chunk(digest, false)? {
                 let hex = hex::encode(digest);
@@ -1349,6 +1351,10 @@ impl DataStore {
                 worker,
             )?;
 
+            info!(
+                "Chunk cache: hits {}, misses {}",
+                gc_status.cache_hits, gc_status.cache_misses,
+            );
             info!(
                 "Removed garbage: {}",
                 HumanByte::from(gc_status.removed_bytes),
-- 
2.39.5





More information about the pbs-devel mailing list