RFC: MI strlen()
delphij at delphij.net
Thu Jan 8 21:01:03 PST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Alfred Perlstein wrote:
> * Xin LI <delphij at delphij.net> [090108 18:27] wrote:
> Here is a new implementation of strlen() which employed the bitmask
> skill in order to achieve better performance on modern hardware. For
> common case, this would be a 5.2x boost on FreeBSD/amd64. The code is
> intended for MI use when there is no hand-optimized assembly.
> Note that this version of strlen() has suboptimal performance if there
> are a lot of characters that has their highest bit set (we can change it
> to have uniform performance at the expense of about ~30% performance
>> It's pretty cool, what does valgrind say when you walk past
>> the end of a string, can it figure that out?
I don't have a runnable valgrind at hand so can't say about it :( This
type of walk past should not cause problem though, as page is always
word aligned and it does not do more speculative read than the old
strlen() implementation (read past a word vs read past a byte against
the page when overrun happen).
Xin LI <delphij at delphij.net> http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
-----END PGP SIGNATURE-----
More information about the freebsd-arch