From owner-freebsd-arch@FreeBSD.ORG Fri Jan 9 04:26:43 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 01C56106566B; Fri, 9 Jan 2009 04:26:43 +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 9BD8C8FC12; Fri, 9 Jan 2009 04:26:42 +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 8BA2B28449; Fri, 9 Jan 2009 12:26:41 +0800 (CST) Received: from localhost (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id 0EE71EC24E2; Fri, 9 Jan 2009 12:26:41 +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 jKR-gSeRfu9I; Fri, 9 Jan 2009 12:26:36 +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 246EFEC225E; Fri, 9 Jan 2009 12:26:34 +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=C9912rRCaArUDyZYUdmihYETouClDKlSYcqZuJx5UN0C6WnwpI1kdHbvJ5iGCbkrY cYWCzsMHaPuREHHkuqT6w== Message-ID: <4966D1F7.1040105@delphij.net> Date: Thu, 08 Jan 2009 20:26:31 -0800 From: Xin LI Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: "Sean C. Farley" References: <4966B5D4.7040709@delphij.net> In-Reply-To: X-Enigmail-Version: 0.95.7 OpenPGP: id=18EDEBA0; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=US-ASCII 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 04:26:43 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Sean, Sean C. Farley wrote: > On Thu, 8 Jan 2009, Xin LI 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? > > I only glanced over it, but I like the idea about having it. > > I see that you investigated this before[1]? Amusingly, I did something Yes, but nothing gets committed :-/ I think I had lost that work due to a hard disk failure. > similar two years later[2] with a C version of strlen()[3]. :) > > Out of curiosity, is an assert (i.e., CTASSERT) better than an #error? Hmm... I did not thought about it, but looking at your code, it seems that using #error makes it more obvious. I have put the revised version at: http://people.freebsd.org/~delphij/for_review/strlen-r1.diff For those who wants to see the file instead of the diff: http://people.freebsd.org/~delphij/for_review/strlen.c Cheers, - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAklm0fcACgkQi+vbBBjt66DWMgCePfKWpIzThVYBRd41lJ3t85KU UrUAoLyiCnnLBBgWk2YbevkZcxHI6XQy =Qhk+ -----END PGP SIGNATURE-----