]> git.ipfire.org Git - thirdparty/glibc.git/commit
Improve strstr performance
authorWilco Dijkstra <wdijkstr@arm.com>
Mon, 16 Jul 2018 16:50:09 +0000 (17:50 +0100)
committerWilco Dijkstra <wdijkstr@arm.com>
Mon, 16 Jul 2018 16:51:52 +0000 (17:51 +0100)
commit3ae725dfb6d7f61447d27d00ed83e573bd5454f4
tree1a0eada529fc06de4613cb84a20d80e5d69c6d0a
parent31e422ca9680bbe412aa56b23f058c10eaee7be8
Improve strstr performance

Improve strstr performance.  Strstr tends to be slow because it uses
many calls to memchr and a slow byte loop to scan for the next match.
Performance is significantly improved by using strnlen on larger blocks
and using strchr to search for the next matching character.  strcasestr
can also use strnlen to scan ahead, and memmem can use memchr to check
for the next match.

On the GLIBC bench tests the performance gains on Cortex-A72 are:
strstr: +25%
strcasestr: +4.3%
memmem: +18%

On a 256KB dataset strstr performance improves by 67%, strcasestr by 47%.

Reviewd-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
ChangeLog
benchtests/bench-strcasestr.c
benchtests/bench-strstr.c
string/memmem.c
string/str-two-way.h
string/strcasestr.c
string/strstr.c
string/test-strcasestr.c
string/test-strstr.c