refs.c: SSE2 optimizations for check_refname_component
PATCH v9 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.
The configure.ac changes include code from the GNU C Library written by Joseph S. Myers <joseph at codesourcery dot com>.
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.
--- git-compat-util.h | 11 +++ refs.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++----- t/t5511-refspec.sh | 20 +++++ 3 files changed, 236 insertions(+), 18 deletions(-)
git-compat-util.h +11 -0
@@ -668,6 +668,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 +205 -18
270 lines not on this page · raw message
t/t5511-refspec.sh +20 -0
@@ -29,6 +29,10 @@ test_refspec push '+:' test_refspec fetch '' test_refspec fetch ':' test_refspec fetch '::' invalid +test_refspec fetch '.' invalid +test_refspec fetch './frotz' invalid +test_refspec fetch 'refs/.' invalid +test_refspec push '*//:refs/remotes/frotz/*' invalid test_refspec push 'refs/heads/*:refs/remotes/frotz/*' test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid
@@ -71,6 +75,9 @@ test_refspec fetch ':refs/remotes/frotz/HEAD-to-me' test_refspec push ':refs/remotes/frotz/delete me' invalid test_refspec fetch ':refs/remotes/frotz/HEAD to me' invalid +test_refspec fetch ':refs/remotes/frotz/something.lock' invalid +test_refspec fetch ':refs/remotes/frotz/a.lock/b' invalid + test_refspec fetch 'refs/heads/*/for-linus:refs/remotes/mine/*-blah' invalid test_refspec push 'refs/heads/*/for-linus:refs/remotes/mine/*-blah' invalid
@@ -88,4 +95,17 @@ test_refspec fetch "refs/heads/${good}" bad=$(printf '\011tab') test_refspec fetch "refs/heads/${bad}" invalid +test_refspec fetch 'refs/heads/a-very-long-refname' +test_refspec fetch 'refs/heads/.a-very-long-refname' invalid +test_refspec fetch 'refs/heads/abcdefgh0123..' invalid +test_refspec fetch 'refs/heads/abcdefgh01234..' invalid +test_refspec fetch 'refs/heads/abcdefgh012345..' invalid +test_refspec fetch 'refs/heads/abcdefgh0123456..' invalid +test_refspec fetch 'refs/heads/abcdefgh01234567..' invalid +test_refspec fetch 'refs/heads/abcdefgh0123.a' +test_refspec fetch 'refs/heads/abcdefgh01234.a' +test_refspec fetch 'refs/heads/abcdefgh012345.a' +test_refspec fetch 'refs/heads/abcdefgh0123456.a' +test_refspec fetch 'refs/heads/abcdefgh01234567.a' + test_done
Signature · 1 line
2.0.0.rc1.24.g0588c94.dirty
Quoted 4 lines · David Turner
git-compat-util.h | 11 +++ refs.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++----- t/t5511-refspec.sh | 20 +++++ 3 files changed, 236 insertions(+), 18 deletions(-)
Hmph, on what branch are you basing your patch? As a follow-up to your dde8a902 (refs.c: optimize check_refname_component(), 2014-06-03) I originally tried to apply it on top of it but it does not seem that the patch is based on that version; nor I have a blob 46139d2 on which the patch claims your refs.c changes are based on.
... goes and looks ...
Ahh, I think I know where it is broken.
refs.c static int check_refname_component(const char *refname, int flags) · line 51
Quoted 9 lines
refs.c +0
-0@@ -46,17 +49,19 @@ static int check_refname_component(const char *refname, int flags)int ch = *cp &255 ;unsigned char disp = refname_disposition[ch];switch (disp) {
There is a stylo here (missing SP after "switch"), which I already have locally fixed before pushing it out on 'next'. I'll fix up this patch and try to apply.
Thanks.