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

Re: 'git checkout' and unlink() calls (was: Re: )

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 8, 2009, 17:57 UTC
Message-ID
<alpine.LFD.2.01.0905081050420.4983@localhost.localdomain>
In-Reply-To
<86y6t77d8t.fsf_-_@broadpark.no>
On Fri, 8 May 2009, Kjetil Barvik wrote:
Show 5 quoted lines
> 
>   So, if the numbers from strace is trustable, 0.71 seconds is used on
>   41 114 calls to lstat64().  But, look at the unlink line, where each
>   call took 259 microseconds (= 0.259 milliseconds), and all 14 379
>   calls took 3.72 seconds.

The system call times from strace are not really trustworthy. The overhead of tracing and in particular all the context switching back and forth between the tracer and the tracee means that the numbers should be taken with a large grain of salt.

That said, they definitely aren't totally made up, and they tend to show real issues.

In this particular case, what is going on is that 'lstat()' does no IO at all, while 'unlink()' generally at the very least will add things to some journal etc, and when the journal fills up, it will force IO.

So doing 15k unlink() calls really is _much_ more expensive than doing 41k lstat() calls, since the latter will never force any IO at all (ok, so even doing just an lstat() may add atime updates etc to directories, but even if atime is enabled, that tends to only trigger one IO per second at most, and we never have to do any sync IO).

>   It should be noted that when switching branch the other way (from .25
>   to .27), the unlink() calls used less time (below 160 microseconds
>   each).

I don't think they are really "260 us each" or "160 us each". It's rather more likely that there are a few that are big due to forced IO, and most are in the couple of us case.

		Linus
Previous: Kjetil Barvik
Message 34 of 34 in “(unknown)”
  1. Bevan WatkissMay 7, 2009
  2. Alex RiesenMay 7, 2009
  3. Bevan WatkissMay 7, 2009
  4. Alex RiesenMay 7, 2009
  5. Bevan WatkissMay 7, 2009
  6. Björn SteinbrinkMay 7, 2009
  7. Linus TorvaldsMay 7, 2009
  8. Bevan WatkissMay 7, 2009
  9. Linus TorvaldsMay 7, 2009
  10. Linus TorvaldsMay 7, 2009
  11. Junio C HamanoMay 7, 2009
  12. Linus TorvaldsMay 7, 2009
  13. Linus TorvaldsMay 7, 2009
  14. david@lang.hmMay 7, 2009
  15. Linus TorvaldsMay 7, 2009
  16. david@lang.hmMay 7, 2009
  17. Linus TorvaldsMay 7, 2009
  18. david@lang.hmMay 7, 2009
  19. Linus TorvaldsMay 7, 2009
  20. david@lang.hmMay 7, 2009
  21. Johan HerlandMay 7, 2009
  22. Bevan WatkissMay 8, 2009
  23. Alex RiesenMay 8, 2009
  24. Linus TorvaldsMay 8, 2009
  25. Brandon CaseyMay 8, 2009
  26. Linus TorvaldsMay 8, 2009
  27. Brandon CaseyMay 8, 2009
  28. Brandon CaseyMay 8, 2009
  29. Linus TorvaldsMay 8, 2009
  30. Brandon CaseyMay 8, 2009
  31. Linus TorvaldsMay 9, 2009
  32. Linus TorvaldsMay 8, 2009
  33. 'git checkout' and unlink() calls (was: Re: )Kjetil Barvik, May 8, 2009
  34. Linus TorvaldsMay 8, 2009

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.