memcpy vs memmove
Hi glibc maintainers,
I have a performance "problem" which I do not understand. If I allocate
a memory buffer of 1 GB (aligned to pagesize) and do a memset(), then
this takes 1.1 seconds. If I copy this buffer to another one using
memcpy(), it takes about 1.7 seconds. But if I use memmove() or bcopy()
it takes only 0.7s and 0.5s:
memset took 1.100437 seconds -> 930.54 MB/s
memcpy took 1.366200 seconds -> 749.52 MB/s
bcopy took 0.703371 seconds -> 1.42 GB/s
memmove took 0.545014 seconds -> 1.83 GB/s
I tried to look at the source code, but got lost somewhere. For me it
looks like they are all using the same code. So I do not understand why
memcpy() is so slow. Do you have any ideas, hints, pointers, ...?
>From the C source it looks identically, but there are also some
assembler codes in the source tree and finally I am not sure which
code is used for which function.
I am using wheezy,
libc6:amd64 2.13-35 amd64
but the squeeze version shows the same behaviour. Maybe there is some
room to optimize memcpy()?
Best regards
Dirk
--
+----------------------------------------------------------------------+
| Dr. Dirk Geschke / Plankensteinweg 61 / 85435 Erding |
| Telefon: 08122-559448 / Mobil: 0176-96906350 / Fax: 08122-9818106 |
| dirk@geschke-online.de / dirk@lug-erding.de / kontakt@lug-erding.de |
+----------------------------------------------------------------------+
Reply to: