Date: Thu, 13 May 2010 23:28:20 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: cvs-src-old@freebsd.org Subject: cvs commit: src/lib/libc/string strlen.c Message-ID: <201005132328.o4DNSWZM088155@repoman.freebsd.org>
index | next in thread | raw e-mail
delphij 2010-05-13 23:28:20 UTC
FreeBSD src repository
Modified files: (Branch: RELENG_8)
lib/libc/string strlen.c
Log:
SVN rev 208051 on 2010-05-13 23:28:20Z by delphij
MFC r205099-205100,205108:
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
Revision Changes Path
1.7.2.2 +45 -25 src/lib/libc/string/strlen.c
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005132328.o4DNSWZM088155>
