From owner-freebsd-arch@FreeBSD.ORG Fri Jan 9 04:43:56 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 C196D106566C for ; Fri, 9 Jan 2009 04:43:56 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.freebsd.org (Postfix) with ESMTP id 8C4F18FC0C for ; Fri, 9 Jan 2009 04:43:56 +0000 (UTC) (envelope-from scf@FreeBSD.org) Received: from [192.168.1.204] (baba.farley.org [192.168.1.204]) by mail.farley.org (8.14.3/8.14.3) with ESMTP id n0944UYO026420; Thu, 8 Jan 2009 22:04:30 -0600 (CST) (envelope-from scf@FreeBSD.org) Date: Thu, 8 Jan 2009 22:04:30 -0600 (CST) From: "Sean C. Farley" To: d@delphij.net In-Reply-To: <4966B5D4.7040709@delphij.net> Message-ID: References: <4966B5D4.7040709@delphij.net> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=3.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail.farley.org Cc: freebsd-arch@FreeBSD.org Subject: Re: RFC: MI strlen() X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list 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:43:57 -0000 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 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? Sean 1. http://lists.freebsd.org/mailman/htdig/freebsd-arch/2005-August/004076.html 2. http://lists.freebsd.org/pipermail/freebsd-arch/2007-July/006636.html 3. http://www.farley.org/freebsd/tmp/strlen/strlen.c -- scf@FreeBSD.org