RFC: MI strlen()
    Sean C. Farley 
    scf at FreeBSD.org
       
    Thu Jan  8 20:43:57 PST 2009
    
    
  
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 at FreeBSD.org
    
    
More information about the freebsd-arch
mailing list