String Routines

We want to optimise the string and memory routines that form part of the standard C library.

  • PENDING: what is the usage distribution for the different routines
    • ...what percentage of a program's time is spent in which routine
    • ...what are the typical arguments (alignments, counts, etc)
    • ...how does this change across program classes

Sources

  • Bionic

    • NEON and non-Neon memcpy()
    • Unknown memcpy(), memset(), memcmp(), memcmp16(), strlen()
    • NetBSD ffs()
    • strcpy() imported from ARM provided code
  • Linux ARM lib

    • Unknown memcpy(), memmove(), memzero()
    • memset() optimised upto 64 bytes/loop (ARM) - note doesn't preserve R0
    • Simple memchr(), strncpy(), srchr(), strnlen()
  • EGLIBC

    • ARMv5 memcpy(), memmove()
    • Unknown memset(), strlen()
    • Note that memcpy() may not be using pld due to not checking for __ARM_ARCH_7__

  • Newlib

    • Thumb-2 strcmp(), strcpy(), and strlen().
  • EFL
    • Block copies and alpha blends in src/lib/engines/common/evas_op_copy/*_neon.c

Use in EGLIBC

EGLIBC is interesting due to the number of architectures supported and the copyright assignment issues.

MichaelHope had a look on 2010-08-16 at EGLIBC 2.11.1-0ubuntu7.2 as supplied by Ubuntu. There are:

  • 132 files that match str*.{s,S}
  • 98 files that match mem*.{s,S}

Some of these are variants that #include or call the real implementation. Removing this gave a total of 178 entries. 18 in ../vax are under a BSD license and the FSF hold the copyright of the remaining 160.

The distribution is interesting. After fixing up a few funny names such as strend-sse4 and rtld-strlen, running `cat tmp.txt |gawk -F / "{ print \$NF }"|sed "s/.[Ss]$//"|sort |uniq -c |sort -rg` gives:

Count

Function

22

memset

21

memcpy

14

strlen

14

strchr

13

strcpy

12

strcmp

11

memchr

8

strncmp

8

memcmp

7

strcat

7

rawmemchr

6

strncpy

5

strrchr

4

strspn

4

strcspn

4

memmove

3

strtok

3

strpbrk

3

strncat

3

strchrnul

1

strtsupp

1

strstr

1

strsep

1

strend

1

mempcpy

1

memccpy

The functions memset, memcpy, strlen, strchr, strcpy, and strcmp cover 54 % of the assembly implementations.

WorkingGroups/ToolChain/StringRoutines (last modified 2011-02-28 16:03:23)