This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Potential issue with strstr on x86 with sse4.2 in glibc-2.18


On Tue, 20 Aug 2013, Rich Felker wrote:

> > The old 4-byte alignment case should only apply to very old binaries, but 
> > of course an old binary using strstr still ought to work on a new system.  
> 
> Or a new binary built with gcc 3.4. While compiling glibc with gcc 3.4
> is not supported, I don't think it's reasonable to tell people they
> can't compile application code with it...

My understanding was that 2.95 and later defaulted to 
-mpreferred-stack-boundary=4, at least in the absence of -Os, so it would 
be saying that particular ABI-breaking options can't be used to build new 
binaries with the old compiler, rather than that it can't be used to build 
new binaries at all.

> > (In the case of strstr, bug 12100 for asymptotic slowness of the SSE4.2 
> > implementation is also still open - though the preference was to use a 
> > hybrid approach for a fix rather than completely removing the SSE4.2 
> > version, so I suppose the realignment issue will remain even with a fix 
> > for that bug.)
> 
> I question the reasoning for this. If the "short needle" version of
> two-way were removed and the "long needle" version (with bad character
> table) always used, I expect it would outperform the SSE code in
> almost all cases. SSE is not at all well-suited to strstr since you
> have to keep bitshifting and check all alignments. At best, the SSE
> code will do one vector comparison per byte of the haystack (up until
> the match, if any, is found). Two-way with the bad character table can
> do much better, on average inspecting only C*n/m positions (where n is
> the haystack length (up to the first match) and m the needle length).

In any case, a fix will need benchmark data, which was lacking for the 
original addition of this SSE4.2 strstr code as well as for the patch to 
remove it that Liubov sent in June 2012 - anyone picking up this bug will 
need to do such benchmarking.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]