cvs commit: src/lib/libc/string strcspn.c strspn.csrc/sys/libkern
strspn.c
Bruce Evans
bde at zeta.org.au
Sat Apr 2 22:55:58 PST 2005
On Sat, 2 Apr 2005, David Schultz wrote:
> BTW, anyone know a good reason why we have optimized string
> functions (e.g. strcmp(), strcpy()) in libc, but not in libkern?
It is because str* functions are almost never used in the kernel.
E.g., to a first approximation, strcmp() is only used for initialization.
Even the non-string function for copying pathnames from user space
(copyinstr()) rarely shows up in profiles. Standard C string functions
are a few orders of magnitude less important than this.
> In testing strcmp(s, s), I found that the libc version on i386 is
> 11% faster when s has length 1 and 4% faster when s has length 400.
That's surprisingly little for an "optimized" asm version versus an
unoptimized C version.
> The kernel has many consumers of these functions, but maybe their
> performance is irrelevant in the grand scheme of things.
> Certainly things like bcopy and bswap are more important...
Except bswap() isn't important. It isn't even used in 4.4BSD-Lite2.
BTW, amd64 doesn't have any "optimized" string functions in userland,
though the "optimization" would actually be an optimization for things
like bcopy() at least.
Bruce
More information about the cvs-src
mailing list