Re: Why Git is so fast
- From
Dmitry Potapov <dpotapov@gmail.com>
- Date
- May 1, 2009, 05:24 UTC
- Message-ID
- <20090501052434.GA4750@dpotapov.dyndns.org>
- In-Reply-To
- <86iqkllw0c.fsf@broadpark.no>
On Thu, Apr 30, 2009 at 10:36:03PM +0200, Kjetil Barvik wrote:
Show 16 quoted lines
> 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.
Dmitry