Re: [PATCH] git gc: Speed it up by 18% via faster hash comparisons
- From
Dmitry Potapov <dpotapov@gmail.com>
- Date
- Apr 28, 2011, 16:36 UTC
- Message-ID
- <BANLkTinfc9J4vhWd9V+ZpXb5tumtZM1jZA@mail.gmail.com>
- In-Reply-To
- <20110428093703.GB15349@elte.hu>
2011/4/28 Ingo Molnar <mingo@elte.hu>:
> > If unsigned char arrays are allocated unaligned then that's another bug i > suspect that should be fixed. Unaligned access on x86 is not free either - > there's cycle penalties.
Unsigned char arrays can be stored unaligned. Basically, it depends on the context in what they were declared. If a preceding field in some structure ended unaligned then the byte array will start unaligned. For example:
struct foo
{
char ch;
unsigned char sha1[20];
};The same on the stack, except the compiler may pack them as it wishes. So, you have no guarantee here. If you want to make sure all SHA-1 are aligned properly, sha1 should be declared as ui32: 'uint32_t sha1[5]'.
Dmitry