From: Toon Claes <toon@iotcl.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Subject: Re: [PATCH 2/4] refs/reftable: don't write new table when expire is a no-op
Date: Wed, 18 Nov 2026 16:34:15 +0100 [thread overview]
Message-ID: <87jymajgqw.fsf@dev.null.iotcl.com.invalid> (raw)
In-Reply-To: <20261118-pks-reflog-expire-performance-v1-2-10b9263566a8@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> When executing `git reflog expire` we may of course end up not expiring
> any reflog entries because none of them are older than "gc.reflogExpire"
> or "gc.reflogExpireUnreachable". But even so, the reftable backend would
> end up writing a new table to disk anyway that contains basically an
> exact copy of the current reflog. And with the "--all" flag, that would
> happen once per existing reflog. This doesn't result in any correctness
> issues, but it is of course a lot of pointless busywork.
>
> Skip writing and committing the new reftable in the case where there
> aren't any changes, which results in a nice speedup:
>
> Benchmark 1: git reflog expire --all (commit = HEAD~) (10 runs)
> mean ± σ min … max
> Wall Time 736.0 ms ± 11.7 ms 720.0 ms … 752.3 ms
> Memory 117.2 MiB ± 0.1 MiB 117.1 MiB … 117.3 MiB
>
> Benchmark 2: git reflog expire --all (commit = HEAD) (10 runs)
> mean ± σ min … max
> Wall Time 370.3 ms ± 3.7 ms 363.4 ms … 375.6 ms -49.7% (2.0x faster)
> Memory 116.8 MiB ± 0.2 MiB 116.5 MiB … 117.1 MiB -0.3%
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> refs/reftable-backend.c | 15 ++++++++++++---
> t/t0610-reftable-basics.sh | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+), 3 deletions(-)
>
> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index 4216a18684d..e2027bb9c02 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -2607,6 +2607,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
> struct strbuf referent = STRBUF_INIT;
> uint8_t *last_hash = NULL;
> size_t logs_nr = 0, logs_alloc = 0, i;
> + bool has_changes = false;
> unsigned int type = 0;
> int ret;
>
> @@ -2696,17 +2697,25 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
> logs[i].value.update.message,
> policy_cb_data)) {
> dest->value_type = REFTABLE_LOG_DELETION;
> + has_changes = true;
> } else {
> - if ((flags & EXPIRE_REFLOGS_REWRITE) && last_hash)
> + if ((flags & EXPIRE_REFLOGS_REWRITE) && last_hash &&
> + memcmp(dest->value.update.old_hash, last_hash,
> + ref_store->repo->hash_algo->rawsz)) {
> memcpy(dest->value.update.old_hash, last_hash, GIT_MAX_RAWSZ);
I cannot help being bothered by using GIT_MAX_RAWSZ here, and
ref_store->repo->hash_algo->rawsz the line above. Would it make sense to
be consistent?
--
Laters,
Toon
next prev parent reply other threads:[~2026-11-18 15:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:30 [PATCH 0/4] Improve performance of reflog expiration Patrick Steinhardt
2026-11-18 9:31 ` [PATCH 1/4] refs/reftable: don't write new table on dry-run expire Patrick Steinhardt
2026-11-18 11:28 ` Karthik Nayak
2026-11-18 12:05 ` Patrick Steinhardt
2026-11-18 16:51 ` Junio C Hamano
2026-11-19 11:59 ` Patrick Steinhardt
2026-11-18 9:31 ` [PATCH 2/4] refs/reftable: don't write new table when expire is a no-op Patrick Steinhardt
2026-11-18 11:33 ` Karthik Nayak
2026-11-18 12:05 ` Patrick Steinhardt
2026-11-18 15:34 ` Toon Claes [this message]
2026-11-19 11:57 ` Patrick Steinhardt
2026-11-18 9:31 ` [PATCH 3/4] builtin/maintenance: only consider `gc.reflogExpire` for "--auto" Patrick Steinhardt
2026-11-18 15:52 ` Toon Claes
2026-11-19 11:58 ` Patrick Steinhardt
2026-11-18 9:31 ` [PATCH 4/4] Documentation/config: fix typo in "maintenance.reflog-expire.auto" Patrick Steinhardt
2026-11-18 15:54 ` Toon Claes
2026-11-18 15:56 ` [PATCH 0/4] Improve performance of reflog expiration Toon Claes
2026-11-19 11:58 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jymajgqw.fsf@dev.null.iotcl.com.invalid \
--to=toon@iotcl.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.