From: David Turner <dturner@twopensource.com>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: git@vger.kernel.org, gitster@pobox.com,
David Turner <dturner@twitter.com>
Subject: Re: [PATCH] check_refname_component: Optimize
Date: Wed, 28 May 2014 19:49:28 -0400 [thread overview]
Message-ID: <1401320968.18134.98.camel@stross> (raw)
In-Reply-To: <538658C0.8050001@alum.mit.edu>
On Wed, 2014-05-28 at 23:44 +0200, Michael Haggerty wrote:
> On 05/28/2014 11:04 PM, David Turner wrote:
> > In a repository with tens of thousands of refs, the command
> > ~/git/git-diff-index --cached --quiet --ignore-submodules [revision]
> > is a bit slow. check_refname_component is a major contributor to the
> > runtime. Provide two optimized versions of this function: one for
> > machines with SSE4.2, and one for machines without. The speedup for
> > this command on one particular repo (with about 60k refs) is about 12%
> > for the SSE version and 8% for the non-SSE version.
>
> Interesting. Thanks for the patch.
Thanks for your thoughtful comments.
> Why do you use "git diff-index" to benchmark your change? Is there
> something particular about that command that leads to especially bad
> performance with lots of references?
Because a colleague specifically asked me to look at it because he uses
it as part of the zsh/bash git prompt dirty bit display. But that is not
actually a good reason to use it in the commit-message. This is also
the reason why milliseconds matter, although at present other parts of
git are slow enough that the prompt stuff is still somewhat infeasible
for large repos.
> I assume that most of the time spent in check_refname_component() is
> while reading the packed-refs file, right?
Yes.
> If so, there are probably
> other git commands that would better measure that time, with less other
> work. For example, "git rev-parse refname" will read the packed-refs
> file, too (assuming that "refname" is not a loose reference). If you
> test the speedup of a cheaper command like that, it seems to me that you
> will get a better idea of how much you are speeding up the ref-reading
> part. It would also be interesting to see the difference in
> milliseconds (rather than a percentage) for some specified number of
> references.
I'll change it to rev-parse and to show the difference in milliseconds.
The times on rev-parse are 35/29/25ms on one particular computer, for
original, LUT, SSE. So, somewhat larger speedup in percentage terms. I
should also note that this represents a real use-case, and I expect that
the number of refs will be somewhat larger in the future.
> I think it's worth using your LUT-based approach to save 8%. I'm less
> sure it's worth the complication and unreadability of using SSE to get
> the next 4% speedup. But the gains might be proven to be more
> significant if you benchmark them differently.
I was actually hoping at some point to use SSE to speed up a small few
of the other slow bits e.g. get_sha1_hex. I have not yet tested if this
will actually be faster, but I bet it will. And my watchman branch uses
it to speed up the hashmap (but it seems CityHash works about as well so
I might just port that instead).
But actually speaking of SSE: is there a minimum compiler version for
git? Because I have just discovered gcc-4.2 on the Mac has a bug which
causes this code to misbehave. Yet again, compiler intrinsics prove
less portable than straight assembly language. I would be just as happy
to write it in assembly, but I suspect that nobody would enjoy that. I
could also work around the bug with a compiler-specific ifdef, but Apple
has been shipping clang for some years now, so I think it's OK to leave
the code as-is.
> I won't critique the code in detail until we have thrashed out the
> metaissues, but I made a few comments below about nits that I noticed
> when I scanned through.
I'll go ahead and roll a new version with the nits picked.
> Please add a comment here about what the values in refname_disposition
> signify. And maybe add some line comments explaining unusual values,
> for people who haven't memorized the ASCII encoding; e.g., on the third
> line,
I think I'm going to say, "see below for the list of illegal characters,
from which this table is derived.", if that's OK with you.
next prev parent reply other threads:[~2014-05-28 23:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-28 21:04 [PATCH v2 0/1] check_refname_component: Optimize David Turner
2014-05-28 21:04 ` [PATCH] " David Turner
2014-05-28 21:44 ` Michael Haggerty
2014-05-28 23:49 ` David Turner [this message]
2014-05-29 13:41 ` Duy Nguyen
2014-05-29 16:36 ` Junio C Hamano
2014-05-29 23:24 ` Duy Nguyen
2014-05-29 23:41 ` Jeff King
2014-05-29 23:43 ` Duy Nguyen
2014-05-30 0:07 ` Jeff King
2014-05-30 2:03 ` Duy Nguyen
2014-05-30 9:47 ` Michael Haggerty
2014-05-30 17:29 ` Jeff King
2014-05-31 10:47 ` Michael Haggerty
2014-05-31 11:21 ` Duy Nguyen
-- strict thread matches above, loose matches on Subject: below --
2014-05-28 19:57 David Turner
2014-05-28 21:24 ` Junio C Hamano
2014-05-29 12:19 ` brian m. carlson
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=1401320968.18134.98.camel@stross \
--to=dturner@twopensource.com \
--cc=dturner@twitter.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
/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).