acadia-newlib/newlib/libc
Wilco Dijkstra 353ebae304 Improve performance of memmem
This patch significantly improves performance of memmem using a novel
modified Horspool algorithm.  Needles up to size 256 use a bad-character
table indexed by hashed pairs of characters to quickly skip past mismatches.
Long needles use a self-adapting filtering step to avoid comparing the whole
needle repeatedly.

By limiting the needle length to 256, the shift table only requires 8 bits
per entry, lowering preprocessing overhead and minimizing cache effects.
This limit also implies worst-case performance is linear.

Small needles up to size 2 use a dedicated linear search.  Very long needles
use the Two-Way algorithm (to avoid increasing stack size inlining is now disabled).

The performance gain is 6.6 times on English text on AArch64 using random
needles with average size 8 (this is even faster than the recently improved strstr
algorithm, so I'll update that in the near future).

The size-optimized memmem has also been rewritten from scratch to get a
2.7x performance gain.

Tested against GLIBC testsuite and randomized tests.

Message-Id: <DB5PR08MB1030649D051FA8532A4512C883B20@DB5PR08MB1030.eurprd08.prod.outlook.com>
2019-01-01 09:44:59 -06:00
..
argz
ctype newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const char *" 2018-10-11 16:32:14 +02:00
errno
iconv
include sys/time.h: Remove KASSERT 2018-12-04 07:39:20 +01:00
locale newlib: Drop incorrect const qualifier from __loadlocale parameter 2018-10-10 11:18:20 +02:00
machine Bump release to 3.1.0 for yearly snapshot 2018-12-31 23:40:11 -05:00
misc
posix Add generic implementation of fdopendir() 2018-10-11 08:29:17 +02:00
reent
search search: Fix Berkeley DB hash code for 16-bit targets. 2018-09-06 17:29:49 +02:00
signal
ssp
stdio nano-vfprintf_float.c: Fix check if negative for nans. 2018-12-13 13:15:32 +01:00
stdio64
stdlib Bump release to 3.1.0 for yearly snapshot 2018-12-31 23:40:11 -05:00
string Improve performance of memmem 2019-01-01 09:44:59 -06:00
sys Bump release to 3.1.0 for yearly snapshot 2018-12-31 23:40:11 -05:00
syscalls
time newlib: strftime: fix over-enthusiastic fix from 0283642f35 2018-08-08 23:59:34 +02:00
unix
xdr xdr_private.h needs sys/types.h for u_char 2018-09-06 14:10:42 +02:00
Makefile.am
Makefile.in
aclocal.m4
configure Bump release to 3.1.0 for yearly snapshot 2018-12-31 23:40:11 -05:00
configure.in
libc.in.xml
libc.texinfo
saber
sys.tex