[PATCH] Improved strlen for ARM, around 29% faster

Gabriel Gonzalez gabriel.gonzalez.garcia at gmail.com
Wed Oct 3 18:38:04 UTC 2012

Hi Rich,

  You replied before I was able to run the test but, yeah, you are
right, my algorithm currently does the test word-based after it hits
an aligned address, using a 3 instruction check to look for the null

  As requested I attach a plot of muslstrlen vs mystrlen, as you
stated my ASM version outperforms the C version.


  Gabriel Gonzalez

On Wed, Oct 3, 2012 at 8:12 PM, Rich Felker <dalias at aerifal.cx> wrote:
> On Wed, Oct 03, 2012 at 01:54:23PM -0400, Rich Felker wrote:
>> On Sat, Sep 29, 2012 at 02:48:48AM +0200, Gabriel Gonzalez wrote:
>> > This version for ARM improves performance mainly unrolling the loop for iterations
>> > and reducing the instructions need to look for the null character.
>> > A deeper analysis of this can be found at http://www.gabrielgonzalezgarcia.com/2012/10/02/mystrlen-vs-android-bionics-strlen-on-arm-cpu/
>> > where you can find some data which back up the performance improvement.
>> > I have only tested it on a little endian CPU so the BIG ENDIAN chunk might need some testing
>> I suspect this code is still considerably slower than the good C
>> implementation, which looks something like:
> Never mind, looks like you're using the good algorithm. And gcc does a
> rather bad job of optimizing it for ARM, so you should be able to beat
> it easily. Cheers.
> Rich
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: muslstrlen_mystrlen.png
Type: image/png
Size: 34515 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20121003/98cd9464/attachment-0001.png>

More information about the uClibc mailing list