Re: [PATCH] describe: limit default ref iteration to tags
- From
Tamir Duberstein <tamird@gmail.com>
- Date
- Jun 8, 2026, 15:53 UTC
- Message-ID
- <CAJ-ks9mdzXQsFpLRgC2zKRABX6aKyTcj1RF2nRb_U8jCj6iVZw@mail.gmail.com>
- In-Reply-To
- <xmqqecihyzse.fsf@gitster.g>
On Mon, Jun 8, 2026 at 5:36 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 23 quoted lines
> > Tamir Duberstein <tamird@gmail.com> writes: > > [jc: Removing Shawn from CC who passed away quite a while ago, RIP]. > > > Unless --all is given, get_name() rejects every ref outside refs/tags/. > > The rejection happens only after the ref backend has enumerated the ref, > > so repositories with many other refs spend most of a simple describe > > invocation visiting refs which cannot affect its result. > > ... > > Both revisions were built with -O3, -mcpu=native, and ThinLTO using > > Apple clang 21.0.0 on macOS 26.5. The machine was a MacBook Pro > > (Mac16,6) with a 16-core Apple M4 Max (12 performance and four > > efficiency cores) and 128 GB RAM. > > > > Signed-off-by: Tamir Duberstein <tamird@gmail.com> > > --- > > builtin/describe.c | 3 +++ > > t/perf/p6100-describe.sh | 20 ++++++++++++++++++++ > > 2 files changed, 23 insertions(+) > > Interesting. How would this relate to and work well with > <20260601233727.43558-1-jacob.e.keller@intel.com>?
They are orthogonal. That patch changes the argument construction inside the `contains` block, which invokes `cmd_name_rev()` and returns. This patch changes the ref iterator used after that block, so it only affects the ordinary, non-`--contains` path.
Show 40 quoted lines
> > > +test_lazy_prereq PERF_REFFILES ' > > + test "$(git rev-parse --show-ref-format)" = files > > +' > > + > > +ref_count=10000 > > + > > # clear out old tags and give us a known state > > test_expect_success 'set up tags' ' > > git for-each-ref --format="delete %(refname)" refs/tags >to-delete && > > @@ -27,4 +33,18 @@ test_perf 'describe HEAD with one tag' ' > > git describe --match=new HEAD > > ' > > > > +test_expect_success PERF_REFFILES 'set up many unrelated refs' ' > > + git tag -m tip tip HEAD && > > + for i in $(test_seq $ref_count) > > + do > > + printf "create refs/heads/describe-perf/%05d HEAD\n" $i || > > + return 1 > > + done >instructions && > > + git update-ref --stdin <instructions > > +' > > + > > +test_perf 'describe exact tag with many loose refs' --prereq PERF_REFFILES ' > > + git describe --exact-match HEAD > > +' > > + > > Is there a strong reason to guard this new test behind > `PERF_REFFILES`? > > Even though the penalty of enumerating 10,000 unrelated loose > references may be most pronounced in the `files` backend, skipping > unnecessary reference enumeration is an architectural win for other > backends (like `reftable` or a fully packed repository) as well. > > If we drop `PERF_REFFILES` and retitle the test to "describe exact > tag with many unrelated refs", we could run it unconditionally to > benchmark the improvement across all storage formats.
Yeah, there's no good reason - and Patrick made the same observation. In v2 I will remove the prerequisite and rename the case to refer to unrelated rather than loose refs.