From ca0e0781c878cf78b2872b0abc096dba2a3f0228 Mon Sep 17 00:00:00 2001 From: Alex Chi Z Date: Thu, 29 Jun 2023 09:56:17 -0400 Subject: [PATCH] use const instead of magic number for repartition threshold (#4286) There is a magic number about how often we repartition and therefore affecting how often we compact. This PR makes this number `10` a global constant and add docs. --------- Signed-off-by: Alex Chi Z --- pageserver/src/tenant/timeline.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 060000a01a..192aa6e22d 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -1298,6 +1298,9 @@ impl Timeline { } } +/// Number of times we will compute partition within a checkpoint distance. +const REPARTITION_FREQ_IN_CHECKPOINT_DISTANCE: u64 = 10; + // Private functions impl Timeline { fn get_checkpoint_distance(&self) -> u64 { @@ -1492,7 +1495,8 @@ impl Timeline { initial_logical_size_can_start, initial_logical_size_attempt: Mutex::new(initial_logical_size_attempt), }; - result.repartition_threshold = result.get_checkpoint_distance() / 10; + result.repartition_threshold = + result.get_checkpoint_distance() / REPARTITION_FREQ_IN_CHECKPOINT_DISTANCE; result .metrics .last_record_gauge