refs.c: SSE2 optimizations for check_refname_component

Optimize check_refname_component using SSE2 on x86_64.

git rev-parse HEAD is a good test-case for this, since it does almost
nothing except parse refs.  For one particular repo with about 60k
refs, almost all packed, the timings are:

Look up table: 29 ms
SSE2:          23 ms

This cuts about 20% off of the runtime.

Ondřej Bílka <neleai@seznam.cz> suggested an SSE2 approach to the
substring searches, which netted a speed boost over the SSE4.2 code I
had initially written.

Signed-off-by: David Turner <dturner@twitter.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
David Turner
2014-06-18 01:54:42 -04:00
committed by Junio C Hamano
parent dde8a902c7
commit 745224e04a
4 changed files with 250 additions and 18 deletions

View File

@ -677,6 +677,17 @@ void git_qsort(void *base, size_t nmemb, size_t size,
#endif
#endif
#if defined(__GNUC__) && defined(__x86_64__)
#include <emmintrin.h>
/*
* This is the system memory page size; it's used so that we can read
* outside the bounds of an allocation without segfaulting.
*/
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
#endif
#ifdef UNRELIABLE_FSTAT
#define fstat_is_reliable() 0
#else