git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Strange O(N^3) behavior in "git filter-branch"

From
Jeff King <peff@peff.net>
Date
Jul 15, 2011, 21:20 UTC
Message-ID
<20110715212059.GA2117@sigill.intra.peff.net>
In-Reply-To
<7vlivz1inu.fsf@alter.siamese.dyndns.org>
On Fri, Jul 15, 2011 at 11:51:49AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> But I think the replace-object codepath should be optimized to realize
> there is no funky replacement (which _is_ a rare configuration) going on
> much early so that it does not incur that much overhead you observed. IOW,
> I tend to agree with your 3. below.
> [...]
> > 3. Optimize the specific case where there is no refs/replace
> > directory--if this directory is missing, then defer populating the loose
> > refs cache in the hope that it will never be needed.
It already tries to do so. It looks like it calls:
  for_each_replace_ref(...)
which calls:
  do_for_each_ref("refs/replace", ...)

which reads _every_ loose ref, regardless of the prefix we have given it. So the optimization should go into the for_each_ref code, which should avoid looking at parts of the hierarchy that are just going to be culled, no?

And then we would see immediately that there is no refs/replace at all, and quit early. And as a bonus, things like "for_each_tag_ref" would get faster in a repository with many branches, too.

-Peff
Previous: Junio C HamanoNext: Michael Haggerty
Message 5 of 11 in “Strange O(N^3) behavior in "git filter-branch"”
  1. Michael HaggertyJul 14, 2011
  2. Michael HaggertyJul 14, 2011
  3. Michael HaggertyJul 15, 2011
  4. Junio C HamanoJul 15, 2011
  5. Jeff KingJul 15, 2011
  6. Michael HaggertyJul 16, 2011
  7. Drew NorthupJul 17, 2011
  8. Jakub NarebskiJul 18, 2011
  9. Drew NorthupJul 18, 2011
  10. Michael HaggertyAug 3, 2011
  11. Jeff KingAug 3, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.