Re: [PATCH 10/11] reftable: make the compaction factor configurable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrick Steinhardt <ps@xxxxxx> writes:

> When auto-compacting, the reftable library packs references such that
> the sizes of the tables form a geometric sequence. The factor for this
> geometric sequence is hardcoded to 2 right now. We're about to expose
> this as a config option though, so let's expose the factor via write
> options.
>
> Signed-off-by: Patrick Steinhardt <ps@xxxxxx>
> ---
>  reftable/reftable-writer.h |  6 ++++++
>  reftable/stack.c           | 13 +++++++++----
>  reftable/stack.h           |  3 ++-
>  reftable/stack_test.c      |  4 ++--
>  4 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/reftable/reftable-writer.h b/reftable/reftable-writer.h
> index 4cd8ebe6c7..155457b042 100644
> --- a/reftable/reftable-writer.h
> +++ b/reftable/reftable-writer.h
> @@ -49,6 +49,12 @@ struct reftable_write_options {
>
>  	/* boolean: Prevent auto-compaction of tables. */
>  	unsigned disable_auto_compact : 1;
> +
> +	/*
> +	 * Geometric sequence factor used by auto-compaction to decide which
> +	 * tables to compact. Defaults to 2 if unset.
> +	 */
> +	uint8_t auto_compaction_factor;
>  };
>
>  /* reftable_block_stats holds statistics for a single block type */
> diff --git a/reftable/stack.c b/reftable/stack.c
> index 7b4fff7c9e..6b0f8e13e7 100644
> --- a/reftable/stack.c
> +++ b/reftable/stack.c
> @@ -1215,12 +1215,16 @@ static int segment_size(struct segment *s)
>  	return s->end - s->start;
>  }
>
> -struct segment suggest_compaction_segment(uint64_t *sizes, size_t n)
> +struct segment suggest_compaction_segment(uint64_t *sizes, size_t n,
> +					  uint8_t factor)
>  {
>  	struct segment seg = { 0 };
>  	uint64_t bytes;
>  	size_t i;
>
> +	if (!factor)
> +		factor = 2;
> +

This should probably go in reftable/constants.h

[snip]

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux