Closed jltobler closed 6 months ago
/submit
Submitted as pull.1683.git.1709669025722.gitgitgadget@gmail.com
To fetch this version into FETCH_HEAD
:
git fetch https://github.com/gitgitgadget/git/ pr-1683/jltobler/jt/reftable-geometric-compaction-v1
To fetch this version to local tag pr-1683/jltobler/jt/reftable-geometric-compaction-v1
:
git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1683/jltobler/jt/reftable-geometric-compaction-v1
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Tue, Mar 05, 2024 at 08:03:45PM +0000, Justin Tobler via GitGitGadget wrote:
> From: Justin Tobler <jltobler@gmail.com>
>
> To reduce the number of on-disk reftables, compaction is performed.
> Contiguous tables with the same binary log value of size are grouped
> into segments. The segment that has both the lowest binary log value and
> contains more than one table is set as the starting point when
> identifying the compaction segment.
>
> Since segments containing a single table are not initially considered
> for compaction, if the table appended to the list does not match the
> previous table log value, no compaction occurs for the new table. It is
> therefore possible for unbounded growth of the table list. This can be
> demonstrated by repeating the following sequence:
>
> git branch -f foo
> git branch -d foo
>
> Each operation results in a new table being written with no compaction
> occurring until a separate operation produces a table matching the
> previous table log value.
>
> To avoid unbounded growth of the table list, walk through each table and
> evaluate if it needs to be included in the compaction segment to restore
> a geometric sequence.
I think the description of what exactly changes could use some more
explanation and some arguments why the new behaviour is okay, too. It's
quite a large rewrite of the compaction logic, so pinpointing exactly
how these are different would go a long way.
> Some tests in `t0610-reftable-basics.sh` assert the on-disk state of
> tables and are therefore updated to specify the correct new table count.
> Since compaction is more aggressive in ensuring tables maintain a
> geometric sequence, the expected table count is reduced in these tests.
> In `reftable/stack_test.c` tests related to `sizes_to_segments()` are
> removed because the function is no longer needed. Also, the
> `test_suggest_compaction_segment()` test is updated to better showcase
> and reflect the new geometric compaction behavior.
>
> Signed-off-by: Justin Tobler <jltobler@gmail.com>
> ---
> reftable/stack: use geometric table compaction
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1683%2Fjltobler%2Fjt%2Freftable-geometric-compaction-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1683/jltobler/jt/reftable-geometric-compaction-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1683
>
> reftable/stack.c | 106 +++++++++++++++----------------------
> reftable/stack.h | 3 --
> reftable/stack_test.c | 66 +++++------------------
> t/t0610-reftable-basics.sh | 24 ++++-----
> 4 files changed, 70 insertions(+), 129 deletions(-)
>
> diff --git a/reftable/stack.c b/reftable/stack.c
> index b64e55648aa..e4ea8753977 100644
> --- a/reftable/stack.c
> +++ b/reftable/stack.c
> @@ -1214,75 +1214,57 @@ static int segment_size(struct segment *s)
> return s->end - s->start;
> }
>
> -int fastlog2(uint64_t sz)
> -{
> - int l = 0;
> - if (sz == 0)
> - return 0;
> - for (; sz; sz /= 2) {
> - l++;
> - }
> - return l - 1;
> -}
> -
> -struct segment *sizes_to_segments(size_t *seglen, uint64_t *sizes, size_t n)
> -{
> - struct segment *segs = reftable_calloc(n, sizeof(*segs));
> - struct segment cur = { 0 };
> - size_t next = 0, i;
> -
> - if (n == 0) {
> - *seglen = 0;
> - return segs;
> - }
> - for (i = 0; i < n; i++) {
> - int log = fastlog2(sizes[i]);
> - if (cur.log != log && cur.bytes > 0) {
> - struct segment fresh = {
> - .start = i,
> - };
> -
> - segs[next++] = cur;
> - cur = fresh;
> - }
> -
> - cur.log = log;
> - cur.end = i + 1;
> - cur.bytes += sizes[i];
> - }
> - segs[next++] = cur;
> - *seglen = next;
> - return segs;
> -}
> -
> struct segment suggest_compaction_segment(uint64_t *sizes, size_t n)
> {
> - struct segment min_seg = {
> - .log = 64,
> - };
> - struct segment *segs;
> - size_t seglen = 0, i;
> -
> - segs = sizes_to_segments(&seglen, sizes, n);
> - for (i = 0; i < seglen; i++) {
> - if (segment_size(&segs[i]) == 1)
> - continue;
> + struct segment seg = { 0 };
> + uint64_t bytes;
> + size_t i;
>
> - if (segs[i].log < min_seg.log)
> - min_seg = segs[i];
> - }
> + /*
> + * If there are no tables or only a single one then we don't have to
> + * compact anything. The sequence is geometric by definition already.
> + */
> + if (n <= 1)
> + return seg;
>
> - while (min_seg.start > 0) {
> - size_t prev = min_seg.start - 1;
> - if (fastlog2(min_seg.bytes) < fastlog2(sizes[prev]))
> + /*
> + * Find the ending table of the compaction segment needed to restore the
> + * geometric sequence.
> + *
> + * To do so, we iterate backwards starting from the most recent table
> + * until a valid segment end is found. If the preceding table is smaller
> + * than the current table multiplied by the geometric factor (2), the
> + * current table is set as the compaction segment end.
> + */
> + for (i = n - 1; i > 0; i--) {
> + if (sizes[i - 1] < sizes[i] * 2) {
> + seg.end = i;
> + bytes = sizes[i];
> break;
> + }
> + }
I was briefly wondering whether we have to compare the _sum_ of all
preceding table sizes to the next size here. Otherwise it may happen
that compaction will lead to a new table that is immediately violating
the geometric sequence again.
But I think due to properties of the geometric sequence, the sum of all
entries preceding the current value cannot be greater than the value
itself. So this should be fine.
This might be worth a comment.
> +
> + /*
> + * Find the starting table of the compaction segment by iterating
> + * through the remaing tables and keeping track of the accumulated size
s/remaing/remaining/
> + * of all tables seen from the segment end table.
> + *
> + * Note that we keep iterating even after we have found the first
> + * first starting point. This is because there may be tables in the
Nit: s/first//, duplicate word.
> + * stack preceding that first starting point which violate the geometric
> + * sequence.
> + */
> + for (; i > 0; i--) {
> + uint64_t curr = bytes;
> + bytes += sizes[i - 1];
>
> - min_seg.start = prev;
> - min_seg.bytes += sizes[prev];
> + if (sizes[i - 1] < curr * 2) {
> + seg.start = i - 1;
> + seg.bytes = bytes;
> + }
> }
Overall I really like the rewritten algorithm, it's a ton easier to
understand compared to the preceding code.
One thing I'd suggest doing though is to provide a benchmark of how the
new compaction strategy compares to the old one. A comparatively easy
way to do this is to write N refs sequentially -- with a big enough N
(e.g. 1 million), compaction time will eventually become an important
factor. So something like the following (untested):
hyperfine \
--prepare "rm -rf repo && git init --ref-format=reftable repo && git -C repo commit --allow-empty --message msg" \
'for ((i = 0 ; i < 1000000; i++ )); do git -C repo update-ref refs/heads/branch-$i HEAD'
>
> - reftable_free(segs);
> - return min_seg;
> + return seg;
> }
>
> static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st)
[snip]
> @@ -737,10 +737,10 @@ test_expect_success 'worktree: pack-refs in main repo packs main refs' '
> test_commit -C repo A &&
> git -C repo worktree add ../worktree &&
>
> - test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
> - test_line_count = 4 repo/.git/reftable/tables.list &&
> + test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> + test_line_count = 1 repo/.git/reftable/tables.list &&
> git -C repo pack-refs &&
> - test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
> + test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> test_line_count = 1 repo/.git/reftable/tables.list
> '
This test needs updating as git-pack-refs(1) has become a no-op here.
> @@ -750,11 +750,11 @@ test_expect_success 'worktree: pack-refs in worktree packs worktree refs' '
> test_commit -C repo A &&
> git -C repo worktree add ../worktree &&
>
> - test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
> - test_line_count = 4 repo/.git/reftable/tables.list &&
> + test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> + test_line_count = 1 repo/.git/reftable/tables.list &&
> git -C worktree pack-refs &&
> test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> - test_line_count = 4 repo/.git/reftable/tables.list
> + test_line_count = 1 repo/.git/reftable/tables.list
> '
Same.
> test_expect_success 'worktree: creating shared ref updates main stack' '
> @@ -770,7 +770,7 @@ test_expect_success 'worktree: creating shared ref updates main stack' '
>
> git -C worktree update-ref refs/heads/shared HEAD &&
> test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> - test_line_count = 2 repo/.git/reftable/tables.list
> + test_line_count = 1 repo/.git/reftable/tables.list
> '
Same.
One thing missing is a test that demonstrates the previously-broken
behaviour.
Patrick
> test_expect_success 'worktree: creating per-worktree ref updates worktree stack' '
>
> base-commit: b387623c12f3f4a376e4d35a610fd3e55d7ea907
> --
> gitgitgadget
>
User Patrick Steinhardt <ps@pks.im>
has been added to the cc: list.
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Tue, Mar 05, 2024 at 08:03:45PM +0000, Justin Tobler via GitGitGadget wrote:
> From: Justin Tobler <jltobler@gmail.com>
> @@ -1305,7 +1287,7 @@ int reftable_stack_auto_compact(struct reftable_stack *st)
> suggest_compaction_segment(sizes, st->merged->stack_len);
> reftable_free(sizes);
> if (segment_size(&seg) > 0)
> - return stack_compact_range_stats(st, seg.start, seg.end - 1,
> + return stack_compact_range_stats(st, seg.start, seg.end,
> NULL);
>
> return 0;
One more thing: I think it would make sense to move the refactoring
where you change whether the end segment index is inclusive or exclusive
into a separate patch so that it's easier to reason about. Also, the
fact that no tests would require changes would further stress the point
that this is a mere refactoring without unintended side effects.
Patrick
There are issues in commit 486be6abb76c372126102425ae359e18fe72d10c:
reftable/stack: Add env to disable autocompaction
Prefixed commit message must be in lower case
There are issues in commit 669a28785690d9678e1c97cbf31478edfcc7f17b:
reftable/segment: Make segment end inclusive
Prefixed commit message must be in lower case
/submit
Submitted as pull.1683.v2.git.1711060819.gitgitgadget@gmail.com
To fetch this version into FETCH_HEAD
:
git fetch https://github.com/gitgitgadget/git/ pr-1683/jltobler/jt/reftable-geometric-compaction-v2
To fetch this version to local tag pr-1683/jltobler/jt/reftable-geometric-compaction-v2
:
git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1683/jltobler/jt/reftable-geometric-compaction-v2
On the Git mailing list, Justin Tobler wrote (reply to this):
On 24/03/06 01:37PM, Patrick Steinhardt wrote:
> On Tue, Mar 05, 2024 at 08:03:45PM +0000, Justin Tobler via GitGitGadget wrote:
> > From: Justin Tobler <jltobler@gmail.com>
> > @@ -1305,7 +1287,7 @@ int reftable_stack_auto_compact(struct reftable_stack *st)
> > suggest_compaction_segment(sizes, st->merged->stack_len);
> > reftable_free(sizes);
> > if (segment_size(&seg) > 0)
> > - return stack_compact_range_stats(st, seg.start, seg.end - 1,
> > + return stack_compact_range_stats(st, seg.start, seg.end,
> > NULL);
> >
> > return 0;
>
> One more thing: I think it would make sense to move the refactoring
> where you change whether the end segment index is inclusive or exclusive
> into a separate patch so that it's easier to reason about. Also, the
> fact that no tests would require changes would further stress the point
> that this is a mere refactoring without unintended side effects.
The `test_suggest_compaction_segment()` in `stack_test.c` does have to
be updated to reflect the segment end now being inclusive. But other
than that, no tests have to be updated.
Thanks Patrick for all the great feedback! I've updated per your
comments in V2 of the patch series.
-Justin
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Thu, Mar 21, 2024 at 10:40:16PM +0000, Justin Tobler via GitGitGadget wrote:
> Hello again,
>
> This is the second version my patch series that refactors the reftable
> compaction strategy to instead follow a geometric sequence. Changes compared
> to v1:
>
> * Added GIT_TEST_REFTABLE_NO_AUTOCOMPACTION environment variable to disable
> reftable compaction when testing.
> * Refactored worktree tests in t0610-reftable-basics.sh to properly assert
> git-pack-refs(1) works as expected.
> * Added test to validate that alternating table sizes are compacted.
> * Added benchmark to compare compaction strategies.
> * Moved change that made compaction segment end inclusive to its own
> commit.
> * Added additional explanation in commits and comments and fixed typos.
>
> Thanks for taking a look!
Cc'ing Han-Wen and Josh for additional input. From my point of view the
new algorithm is simpler to understand and less fragile, but I do wonder
whether there is anything that we're missing.
Patrick
On the Git mailing list, Karthik Nayak wrote (reply to this), regarding def7008452303f71c1fa469609bc199c629a19ec (outdated):
"Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Justin Tobler <jltobler@gmail.com>
>
> To reduce the number of on-disk reftables, compaction is performed.
> Contiguous tables with the same binary log value of size are grouped
> into segments. The segment that has both the lowest binary log value and
> contains more than one table is set as the starting point when
> identifying the compaction segment.
>
> Since segments containing a single table are not initially considered
> for compaction, if the table appended to the list does not match the
> previous table log value, no compaction occurs for the new table. It is
> therefore possible for unbounded growth of the table list. This can be
> demonstrated by repeating the following sequence:
>
Nit: A numerical example would really help make this simpler to understand.
> + /*
> + * Find the ending table of the compaction segment needed to restore the
> + * geometric sequence.
> + *
> + * To do so, we iterate backwards starting from the most recent table
> + * until a valid segment end is found. If the preceding table is smaller
> + * than the current table multiplied by the geometric factor (2), the
> + * current table is set as the compaction segment end.
> + *
> + * Tables after the ending point are not added to the byte count because
> + * they are already valid members of the geometric sequence. Due to the
> + * properties of a geometric sequence, it is not possible for the sum of
> + * these tables to exceed the value of the ending point table.
> + */
> + for (i = n - 1; i > 0; i--) {
> + if (sizes[i - 1] < sizes[i] * 2) {
> + seg.end = i + 1;
> + bytes = sizes[i];
> break;
> + }
> + }
> +
> + /*
> + * Find the starting table of the compaction segment by iterating
> + * through the remaining tables and keeping track of the accumulated
> + * size of all tables seen from the segment end table.
> + *
Nit: we need the accumulated sum because the tables from the end of the
segment will be recursively merged backwards. This might be worthwhile
to add here.
> static void test_suggest_compaction_segment(void)
> {
> - uint64_t sizes[] = { 128, 64, 17, 16, 9, 9, 9, 16, 16 };
> + uint64_t sizes[] = { 512, 64, 17, 16, 9, 9, 9, 16, 2, 16 };
> /* .................0 1 2 3 4 5 6 */
Nit: since we're here, maybe worthwhile cleaning up this comment. Not
sure what it actually is for.
User Karthik Nayak <karthik.188@gmail.com>
has been added to the cc: list.
/submit
Submitted as pull.1683.v3.git.1711685809.gitgitgadget@gmail.com
To fetch this version into FETCH_HEAD
:
git fetch https://github.com/gitgitgadget/git/ pr-1683/jltobler/jt/reftable-geometric-compaction-v3
To fetch this version to local tag pr-1683/jltobler/jt/reftable-geometric-compaction-v3
:
git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1683/jltobler/jt/reftable-geometric-compaction-v3
This branch is now known as jt/reftable-geometric-compaction
.
This patch series was integrated into seen via https://github.com/git/git/commit/c4ecc805c96389d0b6295bf7244654fcce4eeb52.
This patch series was integrated into seen via https://github.com/git/git/commit/71a141bc81c69eb63adab1c9500546534e1058a2.
This patch series was integrated into seen via https://github.com/git/git/commit/95233811253be0013f48da47ae7e0e546a765439.
This patch series was integrated into seen via https://github.com/git/git/commit/99a18e64a367bb86fa89837315a02331afd9d48e.
/submit
Submitted as pull.1683.v4.git.1712103636.gitgitgadget@gmail.com
To fetch this version into FETCH_HEAD
:
git fetch https://github.com/gitgitgadget/git/ pr-1683/jltobler/jt/reftable-geometric-compaction-v4
To fetch this version to local tag pr-1683/jltobler/jt/reftable-geometric-compaction-v4
:
git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1683/jltobler/jt/reftable-geometric-compaction-v4
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Wed, Apr 03, 2024 at 12:20:34AM +0000, Justin Tobler via GitGitGadget wrote:
> Hello again,
>
> This is the fourth version my patch series that refactors the reftable
> compaction strategy to instead follow a geometric sequence. Changes compared
> to v3:
>
> * Changed env name from GIT_TEST_REFTABLE_NO_AUTOCOMPACTION to
> GIT_TEST_REFTABLE_AUTOCOMPACTION and set the default to false. This
You probably mean true here, not false :)
> should hopefully be a bit more intuitive since it avoids the double
> negative.
> * Updated the corresponding env var test in t0610-reftable-basics.sh to
> assert on the number of tables added and be overall less fragile.
> * Folded lines that were too long.
> * Updated some comments in stack.c to more accurately explain that table
> segment end is exclusive.
> * Dropped reftable/stack: make segment end inclusive commit to keep segment
> end exclusive and better follow expectations.
>
> Thanks for taking a look!
This version looks good to me, thanks!
Patrick
> -Justin
>
> Justin Tobler (2):
> reftable/stack: add env to disable autocompaction
> reftable/stack: use geometric table compaction
>
> reftable/stack.c | 126 +++++++++++++++++++------------------
> reftable/stack.h | 3 -
> reftable/stack_test.c | 66 ++++---------------
> reftable/system.h | 1 +
> t/t0610-reftable-basics.sh | 65 +++++++++++++++----
> 5 files changed, 132 insertions(+), 129 deletions(-)
>
>
> base-commit: c75fd8d8150afdf836b63a8e0534d9b9e3e111ba
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1683%2Fjltobler%2Fjt%2Freftable-geometric-compaction-v4
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1683/jltobler/jt/reftable-geometric-compaction-v4
> Pull-Request: https://github.com/gitgitgadget/git/pull/1683
>
> Range-diff vs v3:
>
> 1: 2fdd8ea1133 ! 1: 2a0421e5f20 reftable/stack: add env to disable autocompaction
> @@ Commit message
>
> In future tests it will be neccesary to create repositories with a set
> number of tables. To make this easier, introduce the
> - `GIT_TEST_REFTABLE_NO_AUTOCOMPACTION` environment variable that, when
> - set, disables autocompaction of reftables.
> + `GIT_TEST_REFTABLE_AUTOCOMPACTION` environment variable that, when set
> + to false, disables autocompaction of reftables.
>
> Signed-off-by: Justin Tobler <jltobler@gmail.com>
>
> @@ reftable/stack.c: int reftable_addition_commit(struct reftable_addition *add)
> goto done;
>
> - if (!add->stack->disable_auto_compact)
> -+ if (!add->stack->disable_auto_compact && !git_env_bool("GIT_TEST_REFTABLE_NO_AUTOCOMPACTION", 0))
> ++ if (!add->stack->disable_auto_compact &&
> ++ git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1))
> err = reftable_stack_auto_compact(add->stack);
>
> done:
> @@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: writes cause a
> test_line_count = 1 repo/.git/reftable/tables.list
> '
>
> -+test_expect_success 'ref transaction: environment variable disables auto-compaction' '
> ++test_expect_success 'ref transaction: env var disables compaction' '
> + test_when_finished "rm -rf repo" &&
> +
> + git init repo &&
> + test_commit -C repo A &&
> -+ for i in $(test_seq 20)
> ++
> ++ start=$(wc -l <repo/.git/reftable/tables.list) &&
> ++ iterations=5 &&
> ++ expected=$((start + iterations)) &&
> ++
> ++ for i in $(test_seq $iterations)
> + do
> -+ GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1
> ++ GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
> ++ git -C repo update-ref branch-$i HEAD || return 1
> + done &&
> -+ test_line_count = 23 repo/.git/reftable/tables.list &&
> ++ test_line_count = $expected repo/.git/reftable/tables.list &&
> +
> + git -C repo update-ref foo HEAD &&
> -+ test_line_count = 1 repo/.git/reftable/tables.list
> ++ test_line_count -lt $expected repo/.git/reftable/tables.list
> +'
> +
> check_fsync_events () {
> 2: 7e62c2286ae ! 2: e0f4d0dbcc1 reftable/stack: use geometric table compaction
> @@ reftable/stack.c: static int segment_size(struct segment *s)
> - if (fastlog2(min_seg.bytes) < fastlog2(sizes[prev]))
> + /*
> + * Find the ending table of the compaction segment needed to restore the
> -+ * geometric sequence.
> ++ * geometric sequence. Note that the segment end is exclusive.
> + *
> + * To do so, we iterate backwards starting from the most recent table
> + * until a valid segment end is found. If the preceding table is smaller
> + * than the current table multiplied by the geometric factor (2), the
> -+ * current table is set as the compaction segment end.
> ++ * compaction segment end has been identified.
> + *
> + * Tables after the ending point are not added to the byte count because
> + * they are already valid members of the geometric sequence. Due to the
> @@ reftable/stack.c: static int segment_size(struct segment *s)
> + * Example table size sequence requiring no compaction:
> + * 64, 32, 16, 8, 4, 2, 1
> + *
> -+ * Example compaction segment end set to table with size 3:
> ++ * Example table size sequence where compaction segment end is set to
> ++ * the last table. Since the segment end is exclusive, the last table is
> ++ * excluded during subsequent compaction and the table with size 3 is
> ++ * the final table included:
> + * 64, 32, 16, 8, 4, 3, 1
> + */
> + for (i = n - 1; i > 0; i--) {
> @@ reftable/stack_test.c: static void test_empty_add(void)
> + int l = 0;
> + if (sz == 0)
> + return 0;
> -+ for (; sz; sz /= 2) {
> ++ for (; sz; sz /= 2)
> + l++;
> -+ }
> + return l - 1;
> +}
> +
> @@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: writes cause a
>
> test_commit -C repo --no-tag B &&
> test_line_count = 1 repo/.git/reftable/tables.list
> -@@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: environment variable disables auto-compact
> - do
> - GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo update-ref branch-$i HEAD || return 1
> - done &&
> -- test_line_count = 23 repo/.git/reftable/tables.list &&
> -+ test_line_count = 22 repo/.git/reftable/tables.list &&
> -
> - git -C repo update-ref foo HEAD &&
> - test_line_count = 1 repo/.git/reftable/tables.list
> +@@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: env var disables compaction' '
> + test_line_count -lt $expected repo/.git/reftable/tables.list
> '
>
> +test_expect_success 'ref transaction: alternating table sizes are compacted' '
> + test_when_finished "rm -rf repo" &&
> ++
> + git init repo &&
> + test_commit -C repo A &&
> -+ for i in $(test_seq 20)
> ++ for i in $(test_seq 5)
> + do
> + git -C repo branch -f foo &&
> + git -C repo branch -d foo || return 1
> @@ t/t0610-reftable-basics.sh: test_expect_success 'worktree: pack-refs in main rep
> test_when_finished "rm -rf repo worktree" &&
> git init repo &&
> test_commit -C repo A &&
> -- git -C repo worktree add ../worktree &&
> -+ GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo worktree add ../worktree &&
> -+ GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C worktree update-ref refs/worktree/per-worktree HEAD &&
> ++
> ++ GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
> + git -C repo worktree add ../worktree &&
> ++ GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
> ++ git -C worktree update-ref refs/worktree/per-worktree HEAD &&
>
> - test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
> - test_line_count = 4 repo/.git/reftable/tables.list &&
> @@ t/t0610-reftable-basics.sh: test_expect_success 'worktree: pack-refs in worktree
> test_when_finished "rm -rf repo worktree" &&
> git init repo &&
> test_commit -C repo A &&
> -- git -C repo worktree add ../worktree &&
> -+ GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C repo worktree add ../worktree &&
> -+ GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C worktree update-ref refs/worktree/per-worktree HEAD &&
> ++
> ++ GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
> + git -C repo worktree add ../worktree &&
> ++ GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
> ++ git -C worktree update-ref refs/worktree/per-worktree HEAD &&
>
> - test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
> - test_line_count = 4 repo/.git/reftable/tables.list &&
> @@ t/t0610-reftable-basics.sh: test_expect_success 'worktree: pack-refs in worktree
> '
>
> test_expect_success 'worktree: creating shared ref updates main stack' '
> - test_when_finished "rm -rf repo worktree" &&
> - git init repo &&
> - test_commit -C repo A &&
> -+ test_commit -C repo B &&
> -
> - git -C repo worktree add ../worktree &&
> - git -C repo pack-refs &&
> @@ t/t0610-reftable-basics.sh: test_expect_success 'worktree: creating shared ref updates main stack' '
> test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> test_line_count = 1 repo/.git/reftable/tables.list &&
>
> -- git -C worktree update-ref refs/heads/shared HEAD &&
> -+ GIT_TEST_REFTABLE_NO_AUTOCOMPACTION=true git -C worktree update-ref refs/heads/shared HEAD &&
> ++ GIT_TEST_REFTABLE_AUTOCOMPACTION=false \
> + git -C worktree update-ref refs/heads/shared HEAD &&
> test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
> test_line_count = 2 repo/.git/reftable/tables.list
> - '
> 3: 9a33914c852 < -: ----------- reftable/stack: make segment end inclusive
>
> --
> gitgitgadget
On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):
On Fri, Mar 22, 2024 at 10:51 AM Patrick Steinhardt <ps@pks.im> wrote:
> > Thanks for taking a look!
>
> Cc'ing Han-Wen and Josh for additional input. From my point of view the
> new algorithm is simpler to understand and less fragile, but I do wonder
> whether there is anything that we're missing.
Good spotting. I hadn't thought about alternating tables.
I have one minor criticism:
Environment variables are untyped global variables without any form of
data protection, so I find them unsavoury, and have tried to avoid
them throughout. (The whole reftable library only looks at $TMPDIR in
tests). They're also accessible to end users, so it can become a
feature that can inadvertently become a maintenance burden.
For testing, there is a stack->disable_auto_compact.
If you want to keep that style, I would elevate disable_auto_compact
into reftable_write_options to make it API surface. This will let you
use it in tests written in C, which can be unittests and therefore
more precise and fine-grained. They also run more quickly, and are
easier to instrument with asan/valgrind/etc. The test for tables with
alternating sizes can be easily written in C.
If you really need it, you could initialize disable_auto_compact from
the environment, but I would suggest avoiding it if possible.
--
Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen
User Han-Wen Nienhuys <hanwenn@gmail.com>
has been added to the cc: list.
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Wed, Apr 03, 2024 at 12:13:42PM +0200, Han-Wen Nienhuys wrote:
> On Fri, Mar 22, 2024 at 10:51 AM Patrick Steinhardt <ps@pks.im> wrote:
> > > Thanks for taking a look!
> >
> > Cc'ing Han-Wen and Josh for additional input. From my point of view the
> > new algorithm is simpler to understand and less fragile, but I do wonder
> > whether there is anything that we're missing.
>
> Good spotting. I hadn't thought about alternating tables.
>
> I have one minor criticism:
>
> Environment variables are untyped global variables without any form of
> data protection, so I find them unsavoury, and have tried to avoid
> them throughout. (The whole reftable library only looks at $TMPDIR in
> tests). They're also accessible to end users, so it can become a
> feature that can inadvertently become a maintenance burden.
>
> For testing, there is a stack->disable_auto_compact.
>
> If you want to keep that style, I would elevate disable_auto_compact
> into reftable_write_options to make it API surface. This will let you
> use it in tests written in C, which can be unittests and therefore
> more precise and fine-grained. They also run more quickly, and are
> easier to instrument with asan/valgrind/etc. The test for tables with
> alternating sizes can be easily written in C.
>
> If you really need it, you could initialize disable_auto_compact from
> the environment, but I would suggest avoiding it if possible.
That's actually a good point. I think keeping this as an environment
variable isn't too bad as a stop-gap measure for now, and it should be
obvious to users that it's not for general use due to the `GIT_TEST`
prefix.
But I'm definitely supportive of lifting it out of the reftable library
and into the reftable backend so that it is specific to Git, not to the
reftable library.
Patrick
On the Git mailing list, Karthik Nayak wrote (reply to this):
Hello,
"Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Hello again,
>
> This is the fourth version my patch series that refactors the reftable
> compaction strategy to instead follow a geometric sequence. Changes compared
> to v3:
>
> * Changed env name from GIT_TEST_REFTABLE_NO_AUTOCOMPACTION to
> GIT_TEST_REFTABLE_AUTOCOMPACTION and set the default to false. This
> should hopefully be a bit more intuitive since it avoids the double
> negative.
> * Updated the corresponding env var test in t0610-reftable-basics.sh to
> assert on the number of tables added and be overall less fragile.
> * Folded lines that were too long.
> * Updated some comments in stack.c to more accurately explain that table
> segment end is exclusive.
> * Dropped reftable/stack: make segment end inclusive commit to keep segment
> end exclusive and better follow expectations.
>
> Thanks for taking a look!
>
> -Justin
>
Just a note that this doesn't merge nicely with nice because of
conflicts with a2f711ade0c4816a59155d72559cbc4759cd4699.
On the Git mailing list, Justin Tobler wrote (reply to this):
On 24/04/03 12:18PM, Patrick Steinhardt wrote:
> On Wed, Apr 03, 2024 at 12:13:42PM +0200, Han-Wen Nienhuys wrote:
> > On Fri, Mar 22, 2024 at 10:51 AM Patrick Steinhardt <ps@pks.im> wrote:
> > > > Thanks for taking a look!
> > >
> > > Cc'ing Han-Wen and Josh for additional input. From my point of view the
> > > new algorithm is simpler to understand and less fragile, but I do wonder
> > > whether there is anything that we're missing.
> >
> > Good spotting. I hadn't thought about alternating tables.
> >
> > I have one minor criticism:
> >
> > Environment variables are untyped global variables without any form of
> > data protection, so I find them unsavoury, and have tried to avoid
> > them throughout. (The whole reftable library only looks at $TMPDIR in
> > tests). They're also accessible to end users, so it can become a
> > feature that can inadvertently become a maintenance burden.
> >
> > For testing, there is a stack->disable_auto_compact.
> >
> > If you want to keep that style, I would elevate disable_auto_compact
> > into reftable_write_options to make it API surface. This will let you
> > use it in tests written in C, which can be unittests and therefore
> > more precise and fine-grained. They also run more quickly, and are
> > easier to instrument with asan/valgrind/etc. The test for tables with
> > alternating sizes can be easily written in C.
> >
> > If you really need it, you could initialize disable_auto_compact from
> > the environment, but I would suggest avoiding it if possible.
>
> That's actually a good point. I think keeping this as an environment
> variable isn't too bad as a stop-gap measure for now, and it should be
> obvious to users that it's not for general use due to the `GIT_TEST`
> prefix.
>
> But I'm definitely supportive of lifting it out of the reftable library
> and into the reftable backend so that it is specific to Git, not to the
> reftable library.
Moving the env out of the reftable library seems reasonable to me. I'll
make this change as part of the next version of this series.
-Justin
On the Git mailing list, Junio C Hamano wrote (reply to this):
Patrick Steinhardt <ps@pks.im> writes:
> But I'm definitely supportive of lifting it out of the reftable library
> and into the reftable backend so that it is specific to Git, not to the
> reftable library.
Absolutely. Thanks for bringing up a good point and a nice
solution. I do think it makes sense to handle the environment
variable on the Git side.
This branch is now known as seen
.
On the Git mailing list, Junio C Hamano wrote (reply to this):
Karthik Nayak <karthik.188@gmail.com> writes:
> Just a note that this doesn't merge nicely with nice because of
> conflicts with a2f711ade0c4816a59155d72559cbc4759cd4699.
True. I've been resolving the conflict already, so there is not
much new to see here ;-)
It seems that the plan is to update the section that conflicts even
further to avoid the access to the environment variable, so I'll
have to update my rerere database yet another time.
Thanks.
This branch is now known as jt/reftable-geometric-compaction
.
This patch series was integrated into seen via https://github.com/git/git/commit/27eb770a70dc854ca8df60b7c44d60ddda2a5e27.
On the Git mailing list, Junio C Hamano wrote (reply to this):
"Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes:
> This is the second version my patch series that refactors the reftable
> compaction strategy to instead follow a geometric sequence. Changes compared
> to v1:
>
> * Added GIT_TEST_REFTABLE_NO_AUTOCOMPACTION environment variable to disable
> reftable compaction when testing.
> * Refactored worktree tests in t0610-reftable-basics.sh to properly assert
> git-pack-refs(1) works as expected.
> * Added test to validate that alternating table sizes are compacted.
> * Added benchmark to compare compaction strategies.
> * Moved change that made compaction segment end inclusive to its own
> commit.
> * Added additional explanation in commits and comments and fixed typos.
Has anybody took a look at recent failures with this series present
in 'seen' [*1*] and without [*2*] in osx-reftable jobs for t0610?
*1* https://github.com/git/git/actions/runs/8543205866/job/23406512990
*2* https://github.com/git/git/actions/runs/8543840764/job/23408543876
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Wed, Apr 03, 2024 at 12:12:32PM -0700, Junio C Hamano wrote:
> "Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > This is the second version my patch series that refactors the reftable
> > compaction strategy to instead follow a geometric sequence. Changes compared
> > to v1:
> >
> > * Added GIT_TEST_REFTABLE_NO_AUTOCOMPACTION environment variable to disable
> > reftable compaction when testing.
> > * Refactored worktree tests in t0610-reftable-basics.sh to properly assert
> > git-pack-refs(1) works as expected.
> > * Added test to validate that alternating table sizes are compacted.
> > * Added benchmark to compare compaction strategies.
> > * Moved change that made compaction segment end inclusive to its own
> > commit.
> > * Added additional explanation in commits and comments and fixed typos.
>
> Has anybody took a look at recent failures with this series present
> in 'seen' [*1*] and without [*2*] in osx-reftable jobs for t0610?
>
> *1* https://github.com/git/git/actions/runs/8543205866/job/23406512990
> *2* https://github.com/git/git/actions/runs/8543840764/job/23408543876
I noticed that both `seen` and `next` started to fail in the GitLab
mirror today. Unless somebody else beats me to it I'll investigate
tomorrow what causes these.
Patrick
There was a status update in the "Cooking" section about the branch jt/reftable-geometric-compaction
on the Git mailing list:
The strategy to compat multiple tables of reftables after many operations accumulate many entries has been improved to avoid accumulating too many tables uncollected. Expecting a reroll. cf. <b24jjzw72rlcpctteokr5yfbuwuy2cc3qvibzhuju4gbj63lfa@gbtsmvufyuhd> source: <pull.1683.v4.git.1712103636.gitgitgadget@gmail.com>
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Wed, Apr 03, 2024 at 09:30:19PM +0200, Patrick Steinhardt wrote:
> On Wed, Apr 03, 2024 at 12:12:32PM -0700, Junio C Hamano wrote:
> > "Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes:
> >
> > > This is the second version my patch series that refactors the reftable
> > > compaction strategy to instead follow a geometric sequence. Changes compared
> > > to v1:
> > >
> > > * Added GIT_TEST_REFTABLE_NO_AUTOCOMPACTION environment variable to disable
> > > reftable compaction when testing.
> > > * Refactored worktree tests in t0610-reftable-basics.sh to properly assert
> > > git-pack-refs(1) works as expected.
> > > * Added test to validate that alternating table sizes are compacted.
> > > * Added benchmark to compare compaction strategies.
> > > * Moved change that made compaction segment end inclusive to its own
> > > commit.
> > > * Added additional explanation in commits and comments and fixed typos.
> >
> > Has anybody took a look at recent failures with this series present
> > in 'seen' [*1*] and without [*2*] in osx-reftable jobs for t0610?
> >
> > *1* https://github.com/git/git/actions/runs/8543205866/job/23406512990
> > *2* https://github.com/git/git/actions/runs/8543840764/job/23408543876
>
> I noticed that both `seen` and `next` started to fail in the GitLab
> mirror today. Unless somebody else beats me to it I'll investigate
> tomorrow what causes these.
Things work on GitLab CI again, all pipelines are green there now. Which
probably also is because you have evicted this series from "seen". On
GitHub most of the failures I see are still related to the regression in
libcurl.
But your first link definitely is specific to the changes in this patch
series and comes from a bad interaction with "ps/pack-refs-auto". That
series added a few tests where the exact number of tables that exist is
now different.
Justin wanted to make that series a dependency anyway, so I assume that
he'll then address those issues.
Patrick
/submit
Submitted as pull.1683.v5.git.1712255369.gitgitgadget@gmail.com
To fetch this version into FETCH_HEAD
:
git fetch https://github.com/gitgitgadget/git/ pr-1683/jltobler/jt/reftable-geometric-compaction-v5
To fetch this version to local tag pr-1683/jltobler/jt/reftable-geometric-compaction-v5
:
git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1683/jltobler/jt/reftable-geometric-compaction-v5
On the Git mailing list, Justin Tobler wrote (reply to this):
On 24/04/04 07:34AM, Patrick Steinhardt wrote:
> On Wed, Apr 03, 2024 at 09:30:19PM +0200, Patrick Steinhardt wrote:
> > On Wed, Apr 03, 2024 at 12:12:32PM -0700, Junio C Hamano wrote:
> > > "Justin Tobler via GitGitGadget" <gitgitgadget@gmail.com> writes:
> > >
> > > > This is the second version my patch series that refactors the reftable
> > > > compaction strategy to instead follow a geometric sequence. Changes compared
> > > > to v1:
> > > >
> > > > * Added GIT_TEST_REFTABLE_NO_AUTOCOMPACTION environment variable to disable
> > > > reftable compaction when testing.
> > > > * Refactored worktree tests in t0610-reftable-basics.sh to properly assert
> > > > git-pack-refs(1) works as expected.
> > > > * Added test to validate that alternating table sizes are compacted.
> > > > * Added benchmark to compare compaction strategies.
> > > > * Moved change that made compaction segment end inclusive to its own
> > > > commit.
> > > > * Added additional explanation in commits and comments and fixed typos.
> > >
> > > Has anybody took a look at recent failures with this series present
> > > in 'seen' [*1*] and without [*2*] in osx-reftable jobs for t0610?
> > >
> > > *1* https://github.com/git/git/actions/runs/8543205866/job/23406512990
> > > *2* https://github.com/git/git/actions/runs/8543840764/job/23408543876
> >
> > I noticed that both `seen` and `next` started to fail in the GitLab
> > mirror today. Unless somebody else beats me to it I'll investigate
> > tomorrow what causes these.
>
> Things work on GitLab CI again, all pipelines are green there now. Which
> probably also is because you have evicted this series from "seen". On
> GitHub most of the failures I see are still related to the regression in
> libcurl.
>
> But your first link definitely is specific to the changes in this patch
> series and comes from a bad interaction with "ps/pack-refs-auto". That
> series added a few tests where the exact number of tables that exist is
> now different.
>
> Justin wanted to make that series a dependency anyway, so I assume that
> he'll then address those issues.
Yes, I've made this series depend on "ps/pack-refs-auto" and have
updated the conflicting tests in the next version :)
-Justin
This patch series was integrated into seen via https://github.com/git/git/commit/27efe1efd9e2a70803fc67a8c3997223b4adf168.
There was a status update in the "Cooking" section about the branch jt/reftable-geometric-compaction
on the Git mailing list:
The strategy to compact multiple tables of reftables after many operations accumulate many entries has been improved to avoid accumulating too many tables uncollected. Comments? source: <pull.1683.v5.git.1712255369.gitgitgadget@gmail.com>
This patch series was integrated into seen via https://github.com/git/git/commit/8319fa8c062298303aa475e8c3b40cd335ddfd77.
This patch series was integrated into seen via https://github.com/git/git/commit/59db852aec6d9c8018e9fdc137649fc93eac5bbb.
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Thu, Apr 04, 2024 at 06:29:26PM +0000, Justin Tobler via GitGitGadget wrote:
> Hello again,
>
> This is the fifth version my patch series that refactors the reftable
> compaction strategy to instead follow a geometric sequence. Changes compared
> to v4:
>
> * To fix some failing tests and conflicts, this patch series now depends on
> the ps/pack-refs-auto series which is currently in next.
> * Lifted the GIT_TEST_REFTABLE_AUTOCOMPACTION env out of the reftable
> library and into the reftable backend code.
>
> Thanks for taking a look!
>
> -Justin
I've added two additional nits which you may or may not want to address.
But overall this patch series looks good to me. Thanks!
Patrick
> Justin Tobler (3):
> reftable/stack: allow disabling of auto-compaction
> reftable/stack: add env to disable autocompaction
> reftable/stack: use geometric table compaction
>
> refs/reftable-backend.c | 4 ++
> reftable/reftable-writer.h | 3 +
> reftable/stack.c | 125 +++++++++++++++++++------------------
> reftable/stack.h | 4 --
> reftable/stack_test.c | 77 ++++++-----------------
> t/t0610-reftable-basics.sh | 71 ++++++++++++++++-----
> 6 files changed, 146 insertions(+), 138 deletions(-)
>
>
> base-commit: 4b32163adf4863c6df3bb6b43540fa2ca3494e28
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1683%2Fjltobler%2Fjt%2Freftable-geometric-compaction-v5
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1683/jltobler/jt/reftable-geometric-compaction-v5
> Pull-Request: https://github.com/gitgitgadget/git/pull/1683
>
> Range-diff vs v4:
>
> -: ----------- > 1: a7011dbc6aa reftable/stack: allow disabling of auto-compaction
> 1: 2a0421e5f20 ! 2: 7c4fe0e9ec5 reftable/stack: add env to disable autocompaction
> @@ Commit message
>
> Signed-off-by: Justin Tobler <jltobler@gmail.com>
>
> - ## reftable/stack.c ##
> -@@ reftable/stack.c: int reftable_addition_commit(struct reftable_addition *add)
> - if (err)
> - goto done;
> -
> -- if (!add->stack->disable_auto_compact)
> -+ if (!add->stack->disable_auto_compact &&
> -+ git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1))
> - err = reftable_stack_auto_compact(add->stack);
> -
> - done:
> -
> - ## reftable/system.h ##
> -@@ reftable/system.h: license that can be found in the LICENSE file or at
> - #include "tempfile.h"
> - #include "hash-ll.h" /* hash ID, sizes.*/
> - #include "dir.h" /* remove_dir_recursively, for tests.*/
> + ## refs/reftable-backend.c ##
> +@@
> + #include "../reftable/reftable-merged.h"
> + #include "../setup.h"
> + #include "../strmap.h"
> +#include "parse.h"
> + #include "refs-internal.h"
>
> - int hash_size(uint32_t id);
> + /*
> +@@ refs/reftable-backend.c: static struct ref_store *reftable_be_init(struct repository *repo,
> + refs->write_options.hash_id = repo->hash_algo->format_id;
> + refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
>
> ++ if (!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1))
> ++ refs->write_options.disable_auto_compact = 1;
> ++
> + /*
> + * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.
> + * This stack contains both the shared and the main worktree refs.
>
> ## t/t0610-reftable-basics.sh ##
> @@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: writes cause auto-compaction' '
> 2: e0f4d0dbcc1 ! 3: 8f124acf0f8 reftable/stack: use geometric table compaction
> @@ reftable/stack_test.c: static void test_empty_add(void)
> +
> static void test_reftable_stack_auto_compaction(void)
> {
> - struct reftable_write_options cfg = { 0 };
> + struct reftable_write_options cfg = {
> @@ reftable/stack_test.c: static void test_reftable_stack_compaction_concurrent_clean(void)
> int stack_test_main(int argc, const char *argv[])
> {
> @@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: writes are syn
> EOF
> '
>
> +@@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: fails gracefully when auto compaction fail
> + done ||
> + exit 1
> + done &&
> +- test_line_count = 13 .git/reftable/tables.list
> ++ test_line_count = 10 .git/reftable/tables.list
> + )
> + '
> +
> @@ t/t0610-reftable-basics.sh: test_expect_success 'pack-refs: compacts tables' '
>
> test_commit -C repo A &&
> @@ t/t0610-reftable-basics.sh: test_expect_success 'pack-refs: compacts tables' '
>
> git -C repo pack-refs &&
> ls -1 repo/.git/reftable >table-files &&
> +@@ t/t0610-reftable-basics.sh: test_expect_success "$command: auto compaction" '
> + # The tables should have been auto-compacted, and thus auto
> + # compaction should not have to do anything.
> + ls -1 .git/reftable >tables-expect &&
> +- test_line_count = 4 tables-expect &&
> ++ test_line_count = 3 tables-expect &&
> + git $command --auto &&
> + ls -1 .git/reftable >tables-actual &&
> + test_cmp tables-expect tables-actual &&
> +@@ t/t0610-reftable-basics.sh: test_expect_success "$command: auto compaction" '
> + git branch B &&
> + git branch C &&
> + rm .git/reftable/*.lock &&
> +- test_line_count = 5 .git/reftable/tables.list &&
> ++ test_line_count = 4 .git/reftable/tables.list &&
> +
> + git $command --auto &&
> + test_line_count = 1 .git/reftable/tables.list
> @@ t/t0610-reftable-basics.sh: do
> umask $umask &&
> git init --shared=true repo &&
>
> --
> gitgitgadget
/submit
Submitted as pull.1683.v6.git.1712593016.gitgitgadget@gmail.com
To fetch this version into FETCH_HEAD
:
git fetch https://github.com/gitgitgadget/git/ pr-1683/jltobler/jt/reftable-geometric-compaction-v6
To fetch this version to local tag pr-1683/jltobler/jt/reftable-geometric-compaction-v6
:
git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1683/jltobler/jt/reftable-geometric-compaction-v6
On the Git mailing list, Justin Tobler wrote (reply to this):
On 24/04/08 08:12AM, Patrick Steinhardt wrote:
> On Thu, Apr 04, 2024 at 06:29:26PM +0000, Justin Tobler via GitGitGadget wrote:
> > Hello again,
> >
> > This is the fifth version my patch series that refactors the reftable
> > compaction strategy to instead follow a geometric sequence. Changes compared
> > to v4:
> >
> > * To fix some failing tests and conflicts, this patch series now depends on
> > the ps/pack-refs-auto series which is currently in next.
> > * Lifted the GIT_TEST_REFTABLE_AUTOCOMPACTION env out of the reftable
> > library and into the reftable backend code.
> >
> > Thanks for taking a look!
> >
> > -Justin
>
> I've added two additional nits which you may or may not want to address.
> But overall this patch series looks good to me. Thanks!
Thanks Patrick! I've updated per your suggestions in the next patch
series version.
-Justin
On the Git mailing list, Patrick Steinhardt wrote (reply to this):
On Mon, Apr 08, 2024 at 04:16:52PM +0000, Justin Tobler via GitGitGadget wrote:
> Hello again,
>
> This is the sixth version my patch series that refactors the reftable
> compaction strategy to instead follow a geometric sequence. Changes compared
> to v5:
>
> * Reworded commit message to more clearly explain that the already existing
> configuration to disable auto-compaction is being exposed to callers of
> the library.
> * Simplified expression to set the disable_auto_compact configuration.
>
> Thanks for taking a look!
Thanks, this version looks good to me!
Patrick
> -Justin
>
> Justin Tobler (3):
> reftable/stack: expose option to disable auto-compaction
> reftable/stack: add env to disable autocompaction
> reftable/stack: use geometric table compaction
>
> refs/reftable-backend.c | 3 +
> reftable/reftable-writer.h | 3 +
> reftable/stack.c | 125 +++++++++++++++++++------------------
> reftable/stack.h | 4 --
> reftable/stack_test.c | 77 ++++++-----------------
> t/t0610-reftable-basics.sh | 71 ++++++++++++++++-----
> 6 files changed, 145 insertions(+), 138 deletions(-)
>
>
> base-commit: 4b32163adf4863c6df3bb6b43540fa2ca3494e28
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1683%2Fjltobler%2Fjt%2Freftable-geometric-compaction-v6
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1683/jltobler/jt/reftable-geometric-compaction-v6
> Pull-Request: https://github.com/gitgitgadget/git/pull/1683
>
> Range-diff vs v5:
>
> 1: a7011dbc6aa ! 1: 9c8f6b336ec reftable/stack: allow disabling of auto-compaction
> @@ Metadata
> Author: Justin Tobler <jltobler@gmail.com>
>
> ## Commit message ##
> - reftable/stack: allow disabling of auto-compaction
> + reftable/stack: expose option to disable auto-compaction
> +
> + The reftable stack already has a variable to configure whether or not to
> + run auto-compaction, but it is inaccessible to users of the library.
> + There exist use cases where a caller may want to have more control over
> + auto-compaction.
>
> Move the `disable_auto_compact` option into `reftable_write_options` to
> - allow a stack to be configured with auto-compaction disabled. In a
> - subsequent commit, this is used to disable auto-compaction when a
> - specific environment variable is set.
> + allow external callers to disable auto-compaction. This will be used in
> + a subsequent commit.
>
> Signed-off-by: Justin Tobler <jltobler@gmail.com>
>
> 2: 7c4fe0e9ec5 ! 2: c7bc7346540 reftable/stack: add env to disable autocompaction
> @@ refs/reftable-backend.c
>
> /*
> @@ refs/reftable-backend.c: static struct ref_store *reftable_be_init(struct repository *repo,
> + refs->write_options.block_size = 4096;
> refs->write_options.hash_id = repo->hash_algo->format_id;
> refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
> ++ refs->write_options.disable_auto_compact =
> ++ !git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
>
> -+ if (!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1))
> -+ refs->write_options.disable_auto_compact = 1;
> -+
> /*
> * Set up the main reftable stack that is hosted in GIT_COMMON_DIR.
> - * This stack contains both the shared and the main worktree refs.
>
> ## t/t0610-reftable-basics.sh ##
> @@ t/t0610-reftable-basics.sh: test_expect_success 'ref transaction: writes cause auto-compaction' '
> 3: 8f124acf0f8 = 3: d75494a88b0 reftable/stack: use geometric table compaction
>
> --
> gitgitgadget
On the Git mailing list, Junio C Hamano wrote (reply to this):
Patrick Steinhardt <ps@pks.im> writes:
> On Mon, Apr 08, 2024 at 04:16:52PM +0000, Justin Tobler via GitGitGadget wrote:
>> Hello again,
>>
>> This is the sixth version my patch series that refactors the reftable
>> compaction strategy to instead follow a geometric sequence. Changes compared
>> to v5:
>>
>> * Reworded commit message to more clearly explain that the already existing
>> configuration to disable auto-compaction is being exposed to callers of
>> the library.
>> * Simplified expression to set the disable_auto_compact configuration.
>>
>> Thanks for taking a look!
>
> Thanks, this version looks good to me!
Will queue. I'll mark it for 'next' after I take a brief look for
myself.
Thanks, both.
Hello again,
This is the sixth version my patch series that refactors the reftable compaction strategy to instead follow a geometric sequence. Changes compared to v5:
disable_auto_compact
configuration.Thanks for taking a look!
-Justin
cc: Patrick Steinhardt ps@pks.im cc: Karthik Nayak karthik.188@gmail.com cc: Han-Wen Nienhuys hanwenn@gmail.com