Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Dec 2002 07:27:19 +1100
From:      Peter Jeremy <peter.jeremy@alcatel.com.au>
To:        Anders Gavare <g@dd.chalmers.se>
Cc:        freebsd-alpha@FreeBSD.ORG
Subject:   Re: faster strlen() using longs (?)
Message-ID:  <20021229202719.GC17648@gsmx07.alcatel.com.au>
In-Reply-To: <Pine.GSO.4.44.0212290009180.18017-100000@elros.dd.chalmers.se>
References:  <Pine.GSO.4.44.0212290009180.18017-100000@elros.dd.chalmers.se>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-Dec-29 00:25:49 +0100, Anders Gavare <g@dd.chalmers.se> wrote:
>I'm using FreeBSD 4.5 on an Alpha, and I noticed that strlen() isn't
>implemented using words, but using chars.

This is true of all the strXXX() functions.  The original AXP white
papers include suggestions for efficiently implementing string
functions in the absence of byte operations.  Based on those
suggestions, I implemented bcmp(3) using longs (see
/usr/src/sys/libkern/bcmp.c) - and found that it was faster on
x86 as well.

>I've experimented with several different variations of using longs, and
>this is the fastest one I've come up with. ...
>  It is 2.8 times faster than the default strlen() in libc.

On what sort of CPU?  With what length strings?  What compiler
options?  Have you tried it on a range of different Alpha CPUs?

Peter

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-alpha" in the body of the message




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