git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Fix extraneous lstat's in 'git checkout -f'
Date: Mon, 13 Jul 2009 21:18:04 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0907132107130.13838@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.01.0907132040530.13838@localhost.localdomain>



On Mon, 13 Jul 2009, Linus Torvalds wrote:
> 
> But if both CE_UPTODATE is set, and CE_VALID is clear, then we know that 
> the lstat() will always match the cache entry information, and there's no 
> point in doing another one.

Perf data on the kernel tree and my machine with index preloading:

 - run-of-ten "git checkout -f" before:
	real	0m0.131s
	real	0m0.130s
	real	0m0.128s
	real	0m0.127s
	real	0m0.129s
	real	0m0.135s
	real	0m0.129s
	real	0m0.126s
	real	0m0.128s
	real	0m0.127s

 - run-of-ten "git checkout -f" after:
	real	0m0.105s
	real	0m0.098s
	real	0m0.098s
	real	0m0.116s
	real	0m0.099s
	real	0m0.104s
	real	0m0.097s
	real	0m0.107s
	real	0m0.105s
	real	0m0.101s

so this makes about a 25% performance difference.

HOWEVER! Without preloading, there is bsically no difference what-so-ever, 
because the index won't have been preloaded (duh), so the CE_UPTODATE bit 
won't be set, so we'll do the lstat() in that oneway_merge() function 
regardless.

S for that non-preloading case, I get

 - run-of-ten "git checkout -f" without preloading:
	real	0m0.115s
	real	0m0.116s
	real	0m0.117s
	real	0m0.118s
	real	0m0.120s
	real	0m0.116s
	real	0m0.110s
	real	0m0.110s
	real	0m0.119s
	real	0m0.117s

so what happens is that with that patch the preloading is finally actually 
faster, because now it really helps do the lstat() in parallel (and I have 
lots of cores).

Before the patch, it would do the lstat first in parallel, but then it 
would do _another_ lstat() in the serial code anyway due to the silly 
oneway_merge() thing wasting time on the lstat() even if it didn't need 
to.

I guess I should have made this issue with preloading clear in the commit 
message. 

In other words - the patch should be _much_ more noticeable if you're 
doing something like NFS and are using core.preloadindex=true. My numbers 
above are all hot-cache, so there's no IO, just the fast multi-core CPU.

			Linus

  reply	other threads:[~2009-07-14  4:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14  4:01 Fix extraneous lstat's in 'git checkout -f' Linus Torvalds
2009-07-14  4:18 ` Linus Torvalds [this message]
2009-07-14  8:59 ` Junio C Hamano
2009-07-14 14:50   ` Linus Torvalds
2009-07-14 21:19     ` [PATCH v2] " Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.01.0907132107130.13838@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).