Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 08 Jan 2009 21:00:50 -0800
From:      Xin LI <delphij@delphij.net>
To:        Alfred Perlstein <alfred@freebsd.org>
Cc:        d@delphij.net, freebsd-arch@FreeBSD.org
Subject:   Re: RFC: MI strlen()
Message-ID:  <4966DA02.6060508@delphij.net>
In-Reply-To: <20090109042557.GH60686@elvis.mu.org>
References:  <4966B5D4.7040709@delphij.net> <20090109042557.GH60686@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alfred Perlstein wrote:
> * Xin LI <delphij@delphij.net> [090108 18:27] wrote:
> Hi,
> 
> 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.
> 
> 	http://people.freebsd.org/~delphij/for_review/strlen.diff
> 
> 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
> penalty).
> 
> Comments?
> 
>> 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).

Cheers,
- --
Xin LI <delphij@delphij.net>	http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAklm2gAACgkQi+vbBBjt66C0KACfctSU8/o2ciuu79XYZ21G0VRY
qC0AoIeC/cKp1bHJqxNsVr391BBvzyK9
=kxFV
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4966DA02.6060508>