Thread View: linux.kernel.git
1 messages
1 total messages
Started by Junio C Hamano
Wed, 18 Nov 2026 16:51
Re: [PATCH 1/4] refs/reftable: don't write new table on dry-run expire
Author: Junio C Hamano
Date: Wed, 18 Nov 2026 16:51
Date: Wed, 18 Nov 2026 16:51
61 lines
15311 bytes
15311 bytes
Patrick Steinhardt <ps@pks.im> writes:
> The `git reflog expire` subcommand supports a dry-run flag. When set, we
> print what would be pruned without actually pruning anything on disk.
>
> But even though the expectation is that the on-disk state won't change,
> the reftable backend still ends up writing a new reftable to disk that
> contains the changes. This is of course rather pointless, as we would
> have already printed the entries that we're about to prune at that point
> in time.
I hope I am right in assuming that the current code already has
provisions to discard (or "not to use") this data written to the
disk. If so, that means --dry-run is working correctly, and this
change is a performance-only improvement. Is that the untold piece
of information here?
> Skip writing the data, which provides a small speedup:
>
> Benchmark 1: git reflog expire --all --dry-run (commit = HEAD~) (10 runs)
> mean ± σ min … max
> Wall Time 414.2 ms ± 2.2 ms 411.8 ms … 418.0 ms
> Memory 116.9 MiB ± 0.1 MiB 116.6 MiB … 117.0 MiB
>
> Benchmark 2: git reflog expire --all --dry-run (commit = HEAD) (10 runs)
> mean ± σ min … max
> Wall Time 369.1 ms ± 3.2 ms 361.9 ms … 371.9 ms -10.9%
> Memory 116.8 MiB ± 0.1 MiB 116.7 MiB … 117.0 MiB -0.1%
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> refs/reftable-backend.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index 3ba6a9ac0db..4216a18684d 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -2706,6 +2706,11 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
> if (flags & EXPIRE_REFLOGS_UPDATE_REF && last_hash && !is_null_oid(&oid))
> oidread(&arg.update_oid, last_hash, ref_store->repo->hash_algo);
>
> + if ((flags & EXPIRE_REFLOGS_DRY_RUN)) {
> + ret = 0;
> + goto done;
> + }
> +
> arg.refs = refs;
> arg.records = rewritten;
> arg.len = logs_nr;
> @@ -2720,8 +2725,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
> * Future improvement: we could skip writing records that were
> * not changed.
> */
> - if (!(flags & EXPIRE_REFLOGS_DRY_RUN))
> - ret = reftable_addition_commit(add);
> + ret = reftable_addition_commit(add);
>
> done:
> if (add)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads