From: Tamir Duberstein Date: Mon, 08 Jun 2026 23:56:03 GMT Subject: Re: [PATCH] ref-filter: reuse --contains traversal results Message-ID: In-Reply-To: <20260608235214.GC358144@coredump.intra.peff.net> On Mon, Jun 8, 2026 at 4:52 PM Jeff King wrote: > > On Mon, Jun 08, 2026 at 07:35:57PM -0400, Tamir Duberstein wrote: > > > > So I think a better rule here is to tweak the selection in > > > commit_contains() to select the depth-first algorithm when we have > > > generation numbers enabled. There's a patch in an old thread, which was > > > revived a week or two ago by Kristofer (cc'd): > > > > > > https://lore.kernel.org/git/20260527070510.3510836-1-krka@spotify.com/ > > > > Very good catch, thank you. I reproduced the regression with a > > 100,000-commit history and generation numbers disabled. The parent > > took 13.0 ms, the unconditional depth-first version took 238.4 ms, and > > the generation-aware version took 9.1 ms. > > > > I didn't find a patch in that thread, so I will reroll using the > > memoized walk for tags or when generation numbers are enabled, while > > retaining the breadth-first walk otherwise. If someone else would > > prefer to send that patch, that is fine by me as well. > > It's just this: > > diff --git a/commit-reach.c b/commit-reach.c > index 9b3ea46d6f..cdea0030b8 100644 > --- a/commit-reach.c > +++ b/commit-reach.c > @@ -799,7 +799,8 @@ static enum contains_result contains_tag_algo(struct commit *candidate, > int commit_contains(struct ref_filter *filter, struct commit *commit, > struct commit_list *list, struct contains_cache *cache) > { > - if (filter->with_commit_tag_algo) > + if (filter->with_commit_tag_algo || > + generation_numbers_enabled(the_repository)) > return contains_tag_algo(commit, list, cache) == CONTAINS_YES; > return repo_is_descendant_of(the_repository, commit, list); > } > > from: > > https://lore.kernel.org/git/20230324191009.GA536967@coredump.intra.peff.net/ > > But I won't be surprised if you recreated the identical patch yourself. ;) Yep, that's what happened! > > -Peff Thanks again for all the reviews, v2 of all the patches coming shortly.