From owner-freebsd-arch@FreeBSD.ORG Fri Jan 9 05:01:03 2009 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11523106566B; Fri, 9 Jan 2009 05:01:03 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.delphij.net (delphij-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:2c9::2]) by mx1.freebsd.org (Postfix) with ESMTP id AB85C8FC0A; Fri, 9 Jan 2009 05:01:02 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [211.166.10.233]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.delphij.net (Postfix) with ESMTPS id 5FB9028459; Fri, 9 Jan 2009 13:01:01 +0800 (CST) Received: from localhost (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id 19D18EC25B8; Fri, 9 Jan 2009 13:01:01 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by localhost (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with ESMTP id i0wGNyDolD5P; Fri, 9 Jan 2009 13:00:56 +0800 (CST) Received: from charlie.delphij.net (c-67-188-86-134.hsd1.ca.comcast.net [67.188.86.134]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id 78CEDEB3FAB; Fri, 9 Jan 2009 13:00:54 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=PyRuaEA2vWiE7t9fygbazzyUcOlC6Q5wxLYYopkjp0DAvb8oLu0gBEGj9AEFhznQc VJawheBminvvExO1e6ZWw== Message-ID: <4966DA02.6060508@delphij.net> Date: Thu, 08 Jan 2009 21:00:50 -0800 From: Xin LI Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Alfred Perlstein References: <4966B5D4.7040709@delphij.net> <20090109042557.GH60686@elvis.mu.org> In-Reply-To: <20090109042557.GH60686@elvis.mu.org> X-Enigmail-Version: 0.95.7 OpenPGP: id=18EDEBA0; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: d@delphij.net, freebsd-arch@FreeBSD.org Subject: Re: RFC: MI strlen() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 05:01:03 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Alfred Perlstein wrote: > * Xin LI [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 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-----