This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Improve strstr performance
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, nd <nd at arm dot com>
- Date: Tue, 3 Jul 2018 09:49:19 -0300
- Subject: Re: [PATCH] Improve strstr performance
- References: <HE1PR08MB1035D0511911AA9629E478BE834E0@HE1PR08MB1035.eurprd08.prod.outlook.com>
On 29/06/2018 20:23, Wilco Dijkstra wrote:
> Adhemerval wrote:
>> I am checking if it is worth to keep the implementation in sync with gnulib,
>> since it contains some changes over the years which did not make into glibc.
>>
>> I create a branch with these changes [1] along with your changes, but
>> results are mixed:
>
> Well that's no surprise - the synced code looks much cleaner but will be slower
> without my patch. As is it removes the search for the next matching character,
> so it uses AVAILBLE every character which means even more calls to memchr...
> Your version of my patch removes the FASTSEARCH optimization (maybe missing
> str-two-way.h?), so it loses the main performance gain.
>
> Overall the synced version makes the code far more readable, so it is a good idea
> as a basis for further improvements. However it will only be faster with my patch
> fully merged.
My intention was to check if it would be worth to sync gnulib and then
apply your change on top or the other way around. It seems it would be
better to add your patch and I will propose another with some gnulib
changes (mainly documentation and small optimizations). Some glibc
differences seems more to get around some compiler missed optimization
than actually code improvements (99677e575504 for instance).
>
> This looks dubious and will slow down strcasestr:
>
> -#define TOLOWER(Ch) tolower (Ch)
> +#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
>
> Wilco
>
This was corrected on glibc side and did not get back into gnulib.