Re: [PATCH] describe: limit default ref iteration to tags
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 8, 2026, 12:36 UTC
- Message-ID
- <xmqqecihyzse.fsf@gitster.g>
- In-Reply-To
- <20260607-describe-tag-ref-scope-v1-1-653d232b86b5@gmail.com>
Tamir Duberstein <tamird@gmail.com> writes:
[jc: Removing Shawn from CC who passed away quite a while ago, RIP].
Show 15 quoted lines
> 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>?
Show 27 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.