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

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

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Aug 3, 2011, 13:33 UTC
Message-ID
<4E394E33.4060107@alum.mit.edu>
In-Reply-To
<4E200611.9010005@alum.mit.edu>
On 07/15/2011 11:19 AM, Michael Haggerty wrote:
Show 13 quoted lines
> On 07/14/2011 11:24 AM, Michael Haggerty wrote:
>> On 07/14/2011 09:16 AM, Michael Haggerty wrote:
>>> I have noticed that "git filter-branch" gets pathologically slow when it
>>> operates on a repository that has many references in a complicated
>>> directory hierarchy.  The time seems to go like O(N^3), where N is the
>>> number of references being rewritten.
> [...]
> A many possible improvements come to mind, in increasing order of
> intrusiveness and generality:
> [...]
> 5. Organize the loose refs cache in memory as a tree, and only populate
> the parts of it that are accessed.  This should also speed up iteration
> through a subtree by avoiding a linear search through all loose references.
FYI: I am working on (5), namely storing a linked list of loose refs for
each directory and only populating those directories that are accessed.
 The directories themselves will be held in a tree/trie (AFAICT the
distinction is primarily whether each node holds its whole key or only
the part of the key relative to its parent, which is an implementation
detail).  As a bonus, the caches for submodules will be handled
correctly (they are currently never used).
It might be another week or so before I have patches ready.
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Drew NorthupNext: Jeff King
Message 10 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.