Re: [PATCH] git gc: Speed it up by 18% via faster hash comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2011/4/28 Jonathan Nieder <jrnieder@xxxxxxxxx>:
>
> Hm.  This would be very sensitive to the compiler, since a too-smart
> optimizer could take this loop and rewrite it back to memcmp!  So I
> wonder if it's possible to convey this to the compiler more precisely:
>
>        return memcmp_probably_differs_early(sha1, sha2, 20);
>
> E.g., how would something like
>
>        const unsigned int *start1 = (const unsigned int *) sha1;
>        const unsigned int *start2 = (const unsigned int *) sha2;
>
>        if (likely(*start1 != *start2)) {
>                if (*start1 < *start2)

It can be a problem with unalligned access. So, IMHO, it is
better to use get_be32 here:

        unsigned start1 = get_be32(sha1);
        unsigned start2 = get_be32(sha2);

        if (likely(start1 != start2)) {
                if (start1 < start2)

...

Dmitry
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]