Thread View: linux.kernel.git
1 messages
1 total messages
Started by Karthik Nayak
Wed, 18 Nov 2026 11:28
Re: [PATCH 1/4] refs/reftable: don't write new table on dry-run expire
Author: Karthik Nayak
Date: Wed, 18 Nov 2026 11:28
Date: Wed, 18 Nov 2026 11:28
103 lines
15785 bytes
15785 bytes
--0000000000003af9da06608b4f87
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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.
>
> Skip writing the data, which provides a small speedup:
>
> Benchmark 1: git reflog expire --all --dry-run (commit =3D HEAD~) (10 r=
uns)
> mean =C2=B1 =CF=83 min =E2=80=A6=
max
> Wall Time 414.2 ms =C2=B1 2.2 ms 411.8 ms =E2=80=A6 41=
8.0 ms
> Memory 116.9 MiB =C2=B1 0.1 MiB 116.6 MiB =E2=80=A6 11=
7.0 MiB
>
> Benchmark 2: git reflog expire --all --dry-run (commit =3D HEAD) (10 ru=
ns)
> mean =C2=B1 =CF=83 min =E2=80=A6=
max
> Wall Time 369.1 ms =C2=B1 3.2 ms 361.9 ms =E2=80=A6 37=
1.9 ms -10.9%
> Memory 116.8 MiB =C2=B1 0.1 MiB 116.7 MiB =E2=80=A6 11=
7.0 MiB -0.1%
>
Nice find. Obviously the previous flow was wrong.
> 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_st=
ore *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 =3D 0;
> + goto done;
> + }
> +
> arg.refs =3D refs;
> arg.records =3D rewritten;
> arg.len =3D logs_nr;
> @@ -2720,8 +2725,7 @@ static int reftable_be_reflog_expire(struct ref_sto=
re *ref_store,
> * Future improvement: we could skip writing records that were
> * not changed.
> */
This comment doesn't seem to get removed in the following patch.
> - if (!(flags & EXPIRE_REFLOGS_DRY_RUN))
> - ret =3D reftable_addition_commit(add);
> + ret =3D reftable_addition_commit(add);
>
The changes in this patch look sensible.
> done:
> if (add)
>
> --
> 2.56.1.831.g720f3f5937.dirty
--0000000000003af9da06608b4f87
Content-Type: application/pgp-signature; name="signature.asc"
Content-Disposition: attachment; filename="signature.asc"
Content-Transfer-Encoding: base64
X-Attachment-Id: cc763c47f1f881db_0.1
LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSEtCQUVCQ2dBMEZpRUVWODVNZjJOMWNR
L0xaY1lHUHRXZkpJNUdqSDhGQW1yOWk5VVdIR3RoY25Sb2FXc3UKTVRnNFFHZHRZV2xzTG1OdmJR
QUtDUkErMVo4a2prYU1mK09SQy85OWNtKy9HWCtEcnd0cXM1elhqK3BkM1lFZgpXZ3UxQkx1aVY4
N25kMC82QW1LeXJtZTk0TUpTMHhuc2JjcjBSaXZkUENzclVoSHhSNzFmN1F1QXk2K0pMOEhSCmtl
M2lrVEYyeFF1R2lZb2RLR3lzcVZsV2pWaEdFbEk3bTJwOHdQLytHeVdZbE5LNmwzdDNEdW1FUE1Y
bmZ0SlQKTjF5RFlHV3Ywb3BIRkJuKy9jeUdLUWIyRk1EWWZnNXlJQ2tQbzB6Y3BSSGVKN2ZqVWxP
c09VSmQwOXVsdG5IMApqVms5eHMxVnh1ZVpiZVFPYVZleGxSb25tV0dQSS8xT2lZNWtTT3VHMWUr
cjc5NlYzWjlMSW9ySm9mekZzam91Cmd6MlVIc2s3Qy9JenIyWHpqeHUwT3FaTnlScmZkL0R2RnZl
QlR4TEFKWHg5dE9WRkZVM3RHa2tLOUY5a1FnSVcKSzhJVktSUnU4bnQ5TFlPTndVZmxheFBCRmZU
b0VycG1WbEcxYm9BSWpUenppaE9BQnJjK1Q3ZnIxTmhQKzdSMQpad212aGpmd29RdjkrbkVvbHRM
K1Ntb29EakhlYmJXK29wNUtwcU5IQzNxVGUrejhRVDZ3a3Ryek41NFJ6VElOCnptY3FwYS90cWpv
MFRRQ3hOemJpOW8rWDRKbm4vSVFsMzJlNmpQVT0KPUZGRmgKLS0tLS1FTkQgUEdQIFNJR05BVFVS
RS0tLS0t
--0000000000003af9da06608b4f87--
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