This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Optimize memcmp for ia32


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

H. J. Lu wrote:

> I tested it on all available Pentium 4/M processors.

And because of your tests with P4s you replace the code for generic
i386?  Not very logical, is it?

Furthermore, the test case code is not a realistic benchmark.  For this
you need to know the usual string sizes which happen on a normal system.
 Do you have this data?  Well, I have some code which does measurements
of the use of all string functions.  And guess what the outcome is?
memcmp in the libc is not used at all during a normal system start and
shutdown.  I've even started OO.o.

There are probably places where the calls are handled by gcc and perhaps
there are a few uses inside libc, but that's neglectable and where it is
used the strings are very short.  This means you are optimizing
something which needs no optimizing.  You are increasing the size of
basically dead code.


I've uploaded the data of the string function usage measurements.

  http://people.redhat.com/drepper/string-stat

Something like this

   0: (0/0)=16297   (0/1)=156     (0/2)=1233    (0/3)=212

means string len 0, first parameter aligned 0 (mod 4), second aligned 0
(mod), 1 (mod 4), 2 (mod 4), 3 (mod 4).  The number following the = sign
is the number of calls like this.

If there is only one input string there is only one alignment value.

For memchr()

   2/1   : (0)=2       (1)=3       (2)=2       (3)=2

means input string len 2, character found at index 1 (the columns are
alignment).  You can figure the rest out yourself.

I hope this can prevent wasting energe on useless things and concentrate
optimization for the real world and real string sizes.

- -- 
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAJJNi2ijCOnn/RHQRAjqeAJ4i1Sdp9cD4qcNzdXLMwoVNEvQb/ACdEQ1S
H+6DXCT6PAJtHpov/4MQTf4=
=Y4af
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]