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

Re: Bug Report: git add

From
Jeff King <peff@peff.net>
Date
Apr 8, 2011, 19:46 UTC
Message-ID
<20110408194650.GA15804@sigill.intra.peff.net>
In-Reply-To
<20110408191554.GA6516@sigill.intra.peff.net>
On Fri, Apr 08, 2011 at 03:15:54PM -0400, Jeff King wrote:
Show 10 quoted lines
> > This only checks "does the directory have .git in it?".
> 
> Yeah. I was trying to keep the test as inexpensive as possible, since
> this is a very frequently called codepath. But really, doing a more
> elaborate test shouldn't matter. The common case will be that the stat
> fails, and we do nothing else.
> 
> I do worry about adding an extra lstat for each directory having
> noticeable overhead. Maybe it doesn't matter because of the stat
> caching, but I didn't measure.

I just did some measurements on linux-2.6 (which is a fair bit more directory-heavy than something like git.git). The difference is measurable, but not significant.

The average for "git add ." (on a clean, warm-cache repository) over many trials with the extra lstats is about 2-3% slower. But the error margin between trials is something like 3-4%. IOW, even though the average was worse, the best trial for the new code was still faster than the worst trial for the old.

This is on Linux, though. It would probably be worse on an OS with a slower stat.

-Peff
Previous: Jeff King
Message 13 of 13 in “Bug Report: git add”
  1. Darren CookApr 5, 2011
  2. Ramkumar RamachandraApr 6, 2011
  3. Jakub NarebskiApr 10, 2011
  4. Ramkumar RamachandraApr 10, 2011
  5. Junio C HamanoApr 11, 2011
  6. Jeff KingApr 11, 2011
  7. Jeff KingApr 7, 2011
  8. Junio C HamanoApr 7, 2011
  9. Jeff KingApr 7, 2011
  10. Jeff KingApr 7, 2011
  11. Junio C HamanoApr 7, 2011
  12. Jeff KingApr 8, 2011
  13. Jeff KingApr 8, 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.