public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/4314] New: memcpy performance problem
@ 2007-04-03 20:29 hermantenbrugge at home dot nl
  2007-10-27 14:41 ` [Bug libc/4314] " aj at suse dot de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hermantenbrugge at home dot nl @ 2007-04-03 20:29 UTC (permalink / raw)
  To: glibc-bugs

I have performance problems with memcpy on fedora core 6.
I reduced the problem to the code below:

#include <stdlib.h>
#include <string.h>

int
main(int argc, char **argv)
{
  int i;
  int size;
  int count;
  void *buf1;
  void *buf2;

  if (argc != 3) {
    return 1;
  }
  size = atoi(argv[1]);
  count = atoi(argv[2]);
  buf1 = malloc(size);
  buf2 = malloc(size);
  for (i = 0 ; i < count ; i++) {
    memcpy(buf1, buf2, size);
  }
  return 0;
}

compiled with: gcc a.c -o a -O3

and run with:
/tmp> time ./a 1000 10000000
./a 1000 10000000  2.37s user 0.00s system 99% cpu 2.371 total
/tmp> time ./a 1001 10000000
./a 1001 10000000  6.70s user 0.00s system 99% cpu 6.705 total

The result was surprising to me. When looking at the code I see that
the i686 is using the generic memcpy code and not the optimized i586
code.
I ran the same code on a x86_64 machine. This has the same optimized
code as the i586.
tmp> time ./a 1000 10000000
./a 1000 10000000  1.27s user 0.00s system 99% cpu 1.273 total
tmp> time ./a 1001 10000000
./a 1001 10000000  1.28s user 0.00s system 98% cpu 1.301 total

Can this problem be fixed for the i686? I see that other routines
like memmove is also affected.

-- 
           Summary: memcpy performance problem
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: hermantenbrugge at home dot nl
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=4314

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-04-09 20:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-03 20:29 [Bug libc/4314] New: memcpy performance problem hermantenbrugge at home dot nl
2007-10-27 14:41 ` [Bug libc/4314] " aj at suse dot de
2007-10-27 20:32 ` hermantenbrugge at home dot nl
2007-10-28  5:24 ` aj at suse dot de
2007-10-28  5:53 ` hermantenbrugge at home dot nl
2007-12-15  9:42 ` ismail at pardus dot org dot tr
2008-04-09 20:03 ` drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).