summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/index.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-03-12 21:14:56 +0000
committerdelphij <delphij@FreeBSD.org>2010-03-12 21:14:56 +0000
commitae5ae700daa1f69f414f6066606f705da6e0c1eb (patch)
tree2e52c4428fed96f8449eb4c352f24b2fd04bd300 /lib/libc/string/index.c
parenta5e01102277b659f140548285e631c9572b8827e (diff)
downloadFreeBSD-src-ae5ae700daa1f69f414f6066606f705da6e0c1eb.zip
FreeBSD-src-ae5ae700daa1f69f414f6066606f705da6e0c1eb.tar.gz
Two optimizations to MI strlen(3) inspired by David S. Miller's
blog posting [1]. - Use word-sized test for unaligned pointer before working the hard way. Memory page boundary is always integral multiple of a word alignment boundary. Therefore, if we can access memory referenced by pointer p, then (p & ~word mask) must be also accessible. - Better utilization of multi-issue processor's ability of concurrency. The previous implementation utilized a formular that must be executed sequentially. However, the ~, & and - operations can actually be caculated at the same time when the operand were different and unrelated. The original Hacker's Delight formular also offered consistent performance regardless whether the input would contain characters with their highest-bit set, as it catches real nul characters only. These two optimizations has shown further improvements over the previous implementation on microbenchmarks on i386 and amd64 CPU including Pentium 4, Core Duo 2 and i7. [1] http://vger.kernel.org/~davem/cgi-bin/blog.cgi/2010/03/08#strlen_1 MFC after: 1 month
Diffstat (limited to 'lib/libc/string/index.c')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud