This is the mail archive of the glibc-bugs@sourceware.org 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]

[Bug libc/4314] New: memcpy performance problem


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.


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