Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Apr 2005 16:55:53 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        David Schultz <das@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/lib/libc/string strcspn.c strspn.csrc/sys/libkern strspn.c
Message-ID:  <20050403162709.Q30325@delplex.bde.org>
In-Reply-To: <20050402185706.GA19208@VARK.MIT.EDU>
References:  <200504021852.j32IqjhR031587@repoman.freebsd.org> <20050402185706.GA19208@VARK.MIT.EDU>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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