refs.c: SSE2 optimizations for check_refname_component
PATCH v11 1/1 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 <[email protected]> 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 <[email protected]>
--- git-compat-util.h | 11 +++ refs.c | 234 ++++++++++++++++++++++++++++++++++++++++---- t/t1402-check-ref-format.sh | 15 +++ t/valgrind/default.supp | 8 ++ 4 files changed, 250 insertions(+), 18 deletions(-)
git-compat-util.h +11 -0
@@ -685,6 +685,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
refs.c +216 -18
275 lines not on this page · raw message
t/t1402-check-ref-format.sh +15 -0
@@ -64,6 +64,7 @@ valid_ref "$(printf 'heads/fu\303\237')" invalid_ref 'heads/*foo/bar' --refspec-pattern invalid_ref 'heads/foo*/bar' --refspec-pattern invalid_ref 'heads/f*o/bar' --refspec-pattern +invalid_ref 'heads/foo*//bar' --refspec-pattern ref='foo' invalid_ref "$ref"
@@ -128,6 +129,20 @@ valid_ref NOT_MINGW "$ref" '--allow-onelevel --normalize' invalid_ref NOT_MINGW "$ref" '--refspec-pattern --normalize' valid_ref NOT_MINGW "$ref" '--refspec-pattern --allow-onelevel --normalize' + +valid_ref 'refs/heads/a-very-long-refname' +invalid_ref 'refs/heads/.a-very-long-refname' +invalid_ref 'refs/heads/abcdefgh0123..' +invalid_ref 'refs/heads/abcdefgh01234..' +invalid_ref 'refs/heads/abcdefgh012345..' +invalid_ref 'refs/heads/abcdefgh0123456..' +invalid_ref 'refs/heads/abcdefgh01234567..' +valid_ref 'refs/heads/abcdefgh0123.a' +valid_ref 'refs/heads/abcdefgh01234.a' +valid_ref 'refs/heads/abcdefgh012345.a' +valid_ref 'refs/heads/abcdefgh0123456.a' +valid_ref 'refs/heads/abcdefgh01234567.a' + test_expect_success "check-ref-format --branch @{-1}" ' T=$(git write-tree) && sha1=$(echo A | git commit-tree $T) &&
t/valgrind/default.supp +8 -0
@@ -49,3 +49,11 @@ Memcheck:Addr4 fun:copy_ref } +{ + ignore-sse-check_refname_format + Memcheck:Addr8 + fun:check_refname_format + fun:cmd_check_ref_format + fun:handle_builtin + fun:main +}
Signature · 1 line
2.0.0.rc1.24.g9a2fcb5