This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Improve strstr performance
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: "adhemerval dot zanella at linaro dot org" <adhemerval dot zanella at linaro dot org>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, nd <nd at arm dot com>
- Date: Fri, 29 Jun 2018 23:23:41 +0000
- Subject: Re: [PATCH] Improve strstr performance
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.
This looks dubious and will slow down strcasestr:
-#define TOLOWER(Ch) tolower (Ch)
+#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
Wilco