Subject: Re: [PATCH v6 2/2] refs.c: SSE4.2 optimizations for check_refname_component

From: Torsten Bögershausen <[email-masked]>
Date: Wed, 04 Jun 2014 16:25:47 +0200

On 2014-06-04 13.21, Duy Nguyen wrote:
> On Wed, Jun 4, 2014 at 3:04 PM, Torsten Bögershausen <[email-masked]> wrote:
>>
>> On 2014-06-04 05.38, David Turner wrote:
>> []
>>> []
>>> diff --git a/Makefile b/Makefile
>>> index a53f3a8..dd2127a 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -1326,6 +1326,11 @@ else
>>>               COMPAT_OBJS += compat/win32mmap.o
>>>       endif
>>>  endif
>>> +ifdef NO_SSE42
>>> +     BASIC_CFLAGS += -DNO_SSE42
>>> +else
>>> +     BASIC_CFLAGS += -msse4.2
>>> +endif
>> This does work for some people, but break for others, like the systems in my test-lab.
>> On 2 different systems the gcc has support for -msse4.2, but the processor has not,
>> and t5511 fails with "Illegal instruction".
>> How can that be?
>> The maintainer of a Linux distro wants to ship gcc with all possible features,
>> an the end-user can compile the code with all the features his very processor has.
> 
> I think glibc code uses cpuid instruction to decide whether to use
> optimized version. May be we can do the same? If we go that route and
> have a way to detect sse support from compiler, then we can drop
> NO_SSE42, enable all and pick one at runtime.
> 
Running make under a non-X86 processor like arm fails, as his gcc does not have -msse4.2

On the other hand, looking here: 
http://sourceware.org/ml/libc-alpha/2009-10/msg00063.html
and looking into refs.c,
it seems as if we can try to run 
strcspn(refname, bad_characters)
and 
strstr(refname, "@{"
and 
strstr(refname, ".."
on each refname, instead of checking each char in a loop.
The library will pick the fastest version for strcspn() automatically.

David, the repo you run the tests on, is it public?
Or is there a public repo with this many refs ?
Or can you make a dummy repo with 60k refs ?