From: Jeff King <peff@peff.net>
To: Joey Hess <joey@kitenet.net>
Cc: GIT Mailing-list <git@vger.kernel.org>
Subject: Re: speed of git reset -- file
Date: Wed, 1 Jun 2011 17:18:47 -0400 [thread overview]
Message-ID: <20110601211847.GA31958@sigill.intra.peff.net> (raw)
In-Reply-To: <20110601201629.GA25354@gnu.kitenet.net>
On Wed, Jun 01, 2011 at 04:16:29PM -0400, Joey Hess wrote:
> Jeff King wrote:
> > So implementing the "optimization" to drop the refresh here doesn't seem
> > worth it. It inroduces an awful inconsistency, and it probably isn't
> > saving much in practice. Lots of other commands will end up stat'ing
> > everything, anyway. Users with giant repos or slow stat calls are
> > probably better off using assume-unchanged, which would help this and
> > many other situations.
>
> Sounded like git-reset -q file could be optimised to not reread the
> index without any visible inconsistency?
No, there would still be a visible inconsistency. For example:
$ git reset -q -- file
$ git diff-files
might leave stat-dirty entries in the index, but:
$ git reset -- file
$ git diff-files
would not.
In practice, it doesn't matter that much, because you would probably run
the porcelain "git diff" instead of the plumbing "git diff-files"
anyway. And "git diff" refreshes the index itself, so the behavior
change is not that important. But then, as you see, we end up refreshing
the index defensively a lot, anyway, so saving the one refresh from
reset may be lost in the noise (unless you are doing some tight loop of
resets).
So what you could do with assume-unchanged (or much better, the
autorefreshindex variable that Junio recommends), would be to shut off
_all_ of the unnecessary refreshes, not just this one.
> My experience with semi-large trees[1] is that I have to remember to use
> "git status ." in a subdir; that "git commit -a" is of course slow when
> I need to use it; and that the index gets big and things that need to
> update it can become somewhat slow especially on slow disks, but that
Generally I find that the stats are very fast because everything is in
cache, and the disk doesn't come into it at all. Are you on an OS
besides Linux, or on a machine with low memory?
> otherwise git scales fairly well and has good locality, and that it's
> easy to reason about what operations are global and avoid them.
> So this git-reset behavior was surprising.
Yeah, git is generally very good about touching only the pieces of data
you need to complete the current operation. But I think the decision was
made long ago that "update-index --refresh" was not too expensive to do
it in most porcelain-ish commands, especially since the results are much
better (e.g., more accurately indicating modified files after a reset).
> assume-unchanged seems like it would add a lot of work when merging.
Yeah, Junio's autorefresh suggestion is much better.
-Peff
next prev parent reply other threads:[~2011-06-01 21:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-31 19:00 speed of git reset -- file Joey Hess
2011-05-31 21:26 ` Jeff King
2011-05-31 21:54 ` Junio C Hamano
2011-05-31 22:13 ` Jeff King
2011-05-31 22:13 ` Matthieu Moy
2011-06-01 1:14 ` Nguyen Thai Ngoc Duy
2011-05-31 23:39 ` Junio C Hamano
2011-06-01 19:58 ` Jeff King
2011-06-01 20:16 ` Joey Hess
2011-06-01 21:18 ` Jeff King [this message]
2011-06-01 22:05 ` Joey Hess
2011-06-01 22:56 ` Jeff King
2011-06-01 23:31 ` Joey Hess
2011-06-02 3:18 ` Jeff King
2011-06-02 4:36 ` Joey Hess
2011-06-02 4:46 ` Joey Hess
2011-06-01 20:51 ` Junio C Hamano
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=20110601211847.GA31958@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=joey@kitenet.net \
/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).