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

* [Bug libc/4314] memcpy performance problem
  2007-04-03 20:29 [Bug libc/4314] New: memcpy performance problem hermantenbrugge at home dot nl
@ 2007-10-27 14:41 ` aj at suse dot de
  2007-10-27 20:32 ` hermantenbrugge at home dot nl
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: aj at suse dot de @ 2007-10-27 14:41 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From aj at suse dot de  2007-10-27 14:40 -------
We do use for i686 an optimized memcpy implementation written in assembler.

I see the same performance difference on my system as you do. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|0000-00-00 00:00:00         |2007-10-27 14:40:59
               date|                            |


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

* [Bug libc/4314] memcpy performance problem
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: hermantenbrugge at home dot nl @ 2007-10-27 20:32 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From hermantenbrugge at home dot nl  2007-10-27 20:32 -------
Subject: Re:  memcpy performance problem

aj at suse dot de wrote:
> ------- Additional Comments From aj at suse dot de  2007-10-27 14:40 -------
> We do use for i686 an optimized memcpy implementation written in assembler.
>
> I see the same performance difference on my system as you do. 
>
>   
As far as I call tell the assembler routines are used when configured 
for i586 (not i686). The i686 should use these routines
as well but uses the i386 routines.

    Herman.


-- 


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

* [Bug libc/4314] memcpy performance problem
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: aj at suse dot de @ 2007-10-28  5:24 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From aj at suse dot de  2007-10-28 05:24 -------
for i386 we use the file sysdeps/i386/i686/memcpy.S

-- 


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

* [Bug libc/4314] memcpy performance problem
  2007-04-03 20:29 [Bug libc/4314] New: memcpy performance problem hermantenbrugge at home dot nl
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: hermantenbrugge at home dot nl @ 2007-10-28  5:53 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From hermantenbrugge at home dot nl  2007-10-28 05:53 -------
Subject: Re:  memcpy performance problem

aj at suse dot de wrote:
> ------- Additional Comments From aj at suse dot de  2007-10-28 05:24 -------
> for i386 we use the file sysdeps/i386/i686/memcpy.
>   
correct. This is the assembly file with the problem. We first copy bytes 
until we the length is a multiple of 4 and then do the copy. What 
happens with length not multiple of 4 is that we first copy some bytes 
and then do the rest of the copy with unaligned memory accesses.
The routine that should be used is in: sysdeps/i386/i586/memcpy.S
In fact all sysdeps/i386/i586/* should be used for the i686.


-- 


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

* [Bug libc/4314] memcpy performance problem
  2007-04-03 20:29 [Bug libc/4314] New: memcpy performance problem hermantenbrugge at home dot nl
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: ismail at pardus dot org dot tr @ 2007-12-15  9:42 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ismail at pardus dot org dot
                   |                            |tr


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

* [Bug libc/4314] memcpy performance problem
  2007-04-03 20:29 [Bug libc/4314] New: memcpy performance problem hermantenbrugge at home dot nl
                   ` (4 preceding siblings ...)
  2007-12-15  9:42 ` ismail at pardus dot org dot tr
@ 2008-04-09 20:03 ` drepper at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: drepper at redhat dot com @ 2008-04-09 20:03 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2008-04-09 20:02 -------
I've made some changes.  Checked into cvs.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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).