From 573d4d149b5edebe92485da7c035c42a121a918c Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Fri, 4 Apr 2025 15:07:10 +0200 Subject: [PATCH] pbs-api-types: add garbage collection cache capacity tuning option Allows to adjust the capacity for the LRU cache used to keep track of recently touched chunks during phase 1 of garbage collection. Values are provided as multiples of 1024 cache entries, the default value of 1024 * 1024 was chosen as tradeoff between runtime improvements and memory usage [0]. The maximum of 8192 * 1024 was chosen based on the linear regression from [1], resulting in about 8 * 80 MiB = 640 MiB of memory requirement, while allowing to keep chunks which can reference about 32 TiB of data in case of 4 MiB fixed size chunks. [0] https://git.proxmox.com/?p=proxmox-backup.git;a=commit;h=03143eee0a59cf319be0052e139f7e20e124d572 [1] https://lore.proxmox.com/pbs-devel/fa3800dd-e812-4c9a-9d3d-2d8673e05355@proxmox.com/ Signed-off-by: Christian Ebner Link: https://lore.proxmox.com/pbs-devel/20250404130713.376630-1-c.ebner@proxmox.com Signed-off-by: Thomas Lamprecht --- pbs-api-types/src/datastore.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index b174a047..5bd953ac 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -232,6 +232,13 @@ pub const GC_ATIME_CUTOFF_SCHEMA: Schema = IntegerSchema::new( .default(24 * 60 + 5) .schema(); +pub const GC_CACHE_CAPACITY_SCHEMA: Schema = + IntegerSchema::new("Garbage collection chunk digest cache capacity") + .minimum(0) + .maximum(8 * 1024 * 1024) + .default(1024 * 1024) + .schema(); + #[api( properties: { "chunk-order": { @@ -250,6 +257,10 @@ pub const GC_ATIME_CUTOFF_SCHEMA: Schema = IntegerSchema::new( schema: GC_ATIME_CUTOFF_SCHEMA, optional: true, }, + "gc-cache-capacity": { + schema: GC_CACHE_CAPACITY_SCHEMA, + optional: true, + }, }, )] #[derive(Serialize, Deserialize, Default)] @@ -265,6 +276,8 @@ pub struct DatastoreTuning { pub gc_atime_safety_check: Option, #[serde(skip_serializing_if = "Option::is_none")] pub gc_atime_cutoff: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub gc_cache_capacity: Option, } pub const DATASTORE_TUNING_STRING_SCHEMA: Schema = StringSchema::new("Datastore tuning options")