diff mbox series

[11/11] refs/reftable: allow configuring geometric factor

Message ID 861f2e72d987d17b00d68cdaf400d743e2f8c118.1714630191.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series reftable: expose write options as config | expand

Commit Message

Patrick Steinhardt May 2, 2024, 6:52 a.m. UTC
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>
---
 Documentation/config/reftable.txt | 10 ++++++++++
 refs/reftable-backend.c           |  5 +++++
 2 files changed, 15 insertions(+)

Comments

Karthik Nayak May 10, 2024, 9:58 a.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> 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>
> ---
>  Documentation/config/reftable.txt | 10 ++++++++++
>  refs/reftable-backend.c           |  5 +++++
>  2 files changed, 15 insertions(+)
>
> diff --git a/Documentation/config/reftable.txt b/Documentation/config/reftable.txt
> index 6e4466f3c5..1c381dda04 100644
> --- a/Documentation/config/reftable.txt
> +++ b/Documentation/config/reftable.txt
> @@ -37,3 +37,13 @@ reftable.indexObjects::
>  	are a reverse mapping of object ID to the references pointing to them.
>  +
>  The default value is `true`.
> +
> +reftable.geometricFactor::
> +	Whenever the reftable backend appends a new table to the table it

This doesn't read right, did you mean 's/to the table/,' perhaps?

[snip]
Patrick Steinhardt May 10, 2024, 10:13 a.m. UTC | #2
On Fri, May 10, 2024 at 02:58:58AM -0700, Karthik Nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > 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>
> > ---
> >  Documentation/config/reftable.txt | 10 ++++++++++
> >  refs/reftable-backend.c           |  5 +++++
> >  2 files changed, 15 insertions(+)
> >
> > diff --git a/Documentation/config/reftable.txt b/Documentation/config/reftable.txt
> > index 6e4466f3c5..1c381dda04 100644
> > --- a/Documentation/config/reftable.txt
> > +++ b/Documentation/config/reftable.txt
> > @@ -37,3 +37,13 @@ reftable.indexObjects::
> >  	are a reverse mapping of object ID to the references pointing to them.
> >  +
> >  The default value is `true`.
> > +
> > +reftable.geometricFactor::
> > +	Whenever the reftable backend appends a new table to the table it
> 
> This doesn't read right, did you mean 's/to the table/,' perhaps?

This should rather be "to the stack,". Good catch.

Patrick
diff mbox series

Patch

diff --git a/Documentation/config/reftable.txt b/Documentation/config/reftable.txt
index 6e4466f3c5..1c381dda04 100644
--- a/Documentation/config/reftable.txt
+++ b/Documentation/config/reftable.txt
@@ -37,3 +37,13 @@  reftable.indexObjects::
 	are a reverse mapping of object ID to the references pointing to them.
 +
 The default value is `true`.
+
+reftable.geometricFactor::
+	Whenever the reftable backend appends a new table to the table it
+	performs auto compaction to ensure that there is only a handful of
+	tables. The backend does this by ensuring that tables form a geometric
+	sequence regarding the respective sizes of each table.
++
+By default, the geometric sequence uses a factor of 2, meaning that for any
+table, the next-biggest table must at least be twice as big. A maximum factor
+of 256 is supported.
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 5298fcef6e..657d227c12 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -252,6 +252,11 @@  static int reftable_be_config(const char *var, const char *value,
 	} else if (!strcmp(var, "reftable.indexobjects")) {
 		opts->skip_index_objects = !git_config_bool(var, value);
 		return 0;
+	} else if (!strcmp(var, "reftable.geometricfactor")) {
+		unsigned long factor = git_config_ulong(var, value, ctx->kvi);
+		if (factor > UINT8_MAX)
+			die("reftable geometric factor cannot exceed %u", (unsigned)UINT8_MAX);
+		opts->auto_compaction_factor = factor;
 	}
 
 	return 0;