newlib-cygwin/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 ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
ctype newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const char *" 2018-10-11 16:32:14 +02:00
errno makedoc: make errors visible 2017-12-07 11:54:11 +00:00
iconv ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
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 RISC-V: Do not use _init/_fini 2018-07-30 10:47:57 +02:00
posix Add generic implementation of fdopendir() 2018-10-11 08:29:17 +02:00
reent ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
search search: Fix Berkeley DB hash code for 16-bit targets. 2018-09-06 17:29:49 +02:00
signal Fix newlib functions perror()/psignal() not to use writev(). 2018-07-05 15:33:49 -04:00
ssp makedoc: make errors visible 2017-12-07 11:54:11 +00:00
stdio nano-vfprintf_float.c: Fix check if negative for nans. 2018-12-13 13:15:32 +01:00
stdio64 ansification: remove _EXFNPTR, _EXPARM 2018-01-17 11:47:27 -06:00
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 ansification: remove _HAVE_STDC 2018-01-17 11:47:30 -06:00
time newlib: strftime: fix over-enthusiastic fix from 0283642f35 2018-08-08 23:59:34 +02:00
unix Fix comparison between two character arrays 2018-07-30 09:36:49 +02:00
xdr xdr_private.h needs sys/types.h for u_char 2018-09-06 14:10:42 +02:00
Makefile.am ssp: add build infrastructure 2017-11-29 11:25:46 -06:00
Makefile.in ssp: add build infrastructure 2017-11-29 11:25:46 -06:00
aclocal.m4 Fix up errors in regenerated files for 2.3.0 release. 2016-01-04 12:57:31 -05:00
configure Bump release to 3.1.0 for yearly snapshot 2018-12-31 23:40:11 -05:00
configure.in ssp: add build infrastructure 2017-11-29 11:25:46 -06:00
libc.in.xml ssp: add documentation 2017-11-29 11:25:45 -06:00
libc.texinfo ssp: add documentation 2017-11-29 11:25:45 -06:00
saber
sys.tex Don't include stdio64 functions in reentrant syscalls menu when not bulding stdio64. 2015-08-03 09:54:33 +01:00