[pbs-devel] [PATCH v2 proxmox-backup 2/4] garbage collection: set phase1 LRU cache capacity by tuning option
Christian Ebner
c.ebner at proxmox.com
Fri Apr 4 15:07:11 CEST 2025
Allow to control the capacity of the cache used to track recently
touched chunks via the configured value in the datastore tuning
options. Log the configured value to the task log, if an explicit
value is set, allowing the user to confirm the setting and debug.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 1:
- use raw value for cache capacity, not multiples of 1024
- adapt log message accordingly
pbs-datastore/src/datastore.rs | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 8719c2cdb..95fabea3f 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1113,6 +1113,7 @@ impl DataStore {
&self,
status: &mut GarbageCollectionStatus,
worker: &dyn WorkerTaskContext,
+ cache_capacity: usize,
) -> Result<(), Error> {
// Iterate twice over the datastore to fetch index files, even if this comes with an
// additional runtime cost:
@@ -1128,7 +1129,7 @@ impl DataStore {
let mut unprocessed_index_list = self.list_index_files()?;
let index_count = unprocessed_index_list.len();
- let mut chunk_lru_cache = LruCache::new(1024 * 1024);
+ let mut chunk_lru_cache = LruCache::new(cache_capacity);
let mut processed_index_files = 0;
let mut last_percentage: usize = 0;
@@ -1237,9 +1238,20 @@ impl DataStore {
..Default::default()
};
+ let tuning: DatastoreTuning = serde_json::from_value(
+ DatastoreTuning::API_SCHEMA
+ .parse_property_string(gc_store_config.tuning.as_deref().unwrap_or(""))?,
+ )?;
+ let gc_cache_capacity = if let Some(capacity) = tuning.gc_cache_capacity {
+ info!("Using chunk digest cache capacity of {capacity}.");
+ capacity
+ } else {
+ 1024 * 1024
+ };
+
info!("Start GC phase1 (mark used chunks)");
- self.mark_used_chunks(&mut gc_status, worker)
+ self.mark_used_chunks(&mut gc_status, worker, gc_cache_capacity)
.context("marking used chunks failed")?;
info!("Start GC phase2 (sweep unused chunks)");
--
2.39.5
More information about the pbs-devel
mailing list