Re: Why Git is so fast
- From
Mike Hommey <mh@glandium.org>
- Date
- May 1, 2009, 09:42 UTC
- Message-ID
- <20090501094221.GB13264@glandium.org>
- In-Reply-To
- <20090501052434.GA4750@dpotapov.dyndns.org>
On Fri, May 01, 2009 at 09:24:34AM +0400, Dmitry Potapov wrote:
Show 22 quoted lines
> On Thu, Apr 30, 2009 at 10:36:03PM +0200, Kjetil Barvik wrote:
> > 4) The "static inline void hashcpy(....)" in cache.h could then
> > maybe be written like this:
> >
> > static inline void hashcpy(unsigned long sha_dst[5], const unsigned long sha_src[5])
> > {
> > sha_dst[0] = sha_src[0];
> > sha_dst[1] = sha_src[1];
> > sha_dst[2] = sha_src[2];
> > sha_dst[3] = sha_src[3];
> > sha_dst[4] = sha_src[4];
> > }
> >
> > And hopefully will be compiled to just 5 store/more
> > instructions, or at least hopefully be faster than the currently
> > memcpy() call. But mabye we get more compiled instructions compared
> > to a single call to memcpy()?
>
> Good compilers can inline memcpy and should produce more efficient code
> for the target architecture, which can be faster than manually written.
> On x86_64, memcpy() requires only 3 load/store operations to copy SHA-1
> while the above code requires 5 operations.I guess, though, that some enforced alignment could help produce slightly more efficient code on some architectures (most notably sparc, which really doesn't like to deal with unaligned words).
Mike