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

Re: Set up for better tree diff optimizations

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 21, 2007, 18:21 UTC
Message-ID
<Pine.LNX.4.64.0703211110050.6730@woody.linux-foundation.org>
In-Reply-To
<7vslby1qvw.fsf@assigned-by-dhcp.cox.net>
On Wed, 21 Mar 2007, Junio C Hamano wrote:
> 
> As always, you are right and enlightened others with your
> superiour intelligence enough to produce code for you so that
> you do not have to write yourself ;-).

What can I say? It's a gift. I write _just_ enough code so that others get intrigued and encouraged to do the rest. Then I step in, and take all the glory.

> Would something like this suit your taste?

This looks fine, although the reason I didn't get it done myself is that I have this nagging feeling that there must be some clever way to make it even faster. I hated having to do the "strncmp()" early, when it's not always needed.

But like your patch, I could never come up with a way to *both* do the "don't strncmp() if you don't have to" *and* do the "nothing further will be interesting any more" optimization..

That said, your numbers are pretty convincing:
> The "rev-list org.eclipse.debug.ui/" test that took 16-17
> seconds takes 9 seconds with this patch.  Running with a
> diffrent pathspec "org.apache.ant/" obviously makes it go a lot
> faster (15sec vs 7sec).

Yeah, and conversely, a pathspec at the end of the list of paths will make it less of an optimization. But in general it shouldn't ever be a loss except for the rather rare case of asking for a path at the end of a tree, and then the loss should be pretty small (ie it's the result of doing a few strncmp's that we used to be able to skip).

Considering that the win on _average_ is in the 50% range (and your numbers back that up), it's definitely worth it.

		Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “Set up for better tree diff optimizations”
  1. Linus TorvaldsMar 18, 2007
  2. Junio C HamanoMar 21, 2007
  3. Linus TorvaldsMar 21, 2007
  4. Junio C HamanoMar 21, 2007
  5. Linus TorvaldsMar 21, 2007
  6. Junio C HamanoMar 21, 2007
  7. Junio C HamanoMar 21, 2007
  8. Junio C HamanoMar 22, 2007

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.