refs/reftable: allow configuring geometric factor

Allow configuring the geometric factor used by the auto-compaction algorithm whenever a new table is appended to the stack of tables. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed May 13, 2024 at 10:18 UTC f518d91a2b6465c9951f4ee1ab316ee81894000c
2 files changed +15
Documentation/config/reftable.txt
+10
@@ -36,3 +36,13 @@ reftable.indexObjects::
36 are a reverse mapping of object ID to the references pointing to them.
37 +
38 The default value is `true`.
39 +
40 +reftable.geometricFactor::
41 + Whenever the reftable backend appends a new table to the stack, it
42 + performs auto compaction to ensure that there is only a handful of
43 + tables. The backend does this by ensuring that tables form a geometric
44 + sequence regarding the respective sizes of each table.
45 ++
46 +By default, the geometric sequence uses a factor of 2, meaning that for any
47 +table, the next-biggest table must at least be twice as big. A maximum factor
48 +of 256 is supported.
refs/reftable-backend.c
+5
@@ -247,6 +247,11 @@ static int reftable_be_config(const char *var, const char *value,
247 opts->restart_interval = restart_interval;
248 } else if (!strcmp(var, "reftable.indexobjects")) {
249 opts->skip_index_objects = !git_config_bool(var, value);
250 + } else if (!strcmp(var, "reftable.geometricfactor")) {
251 + unsigned long factor = git_config_ulong(var, value, ctx->kvi);
252 + if (factor > UINT8_MAX)
253 + die("reftable geometric factor cannot exceed %u", (unsigned)UINT8_MAX);
254 + opts->auto_compaction_factor = factor;
255 }
256
257 return 0;