This is the mail archive of the
mailing list for the libstdc++ project.
Re: Performance of copy algorithm
- From: Matt Austern <austern at apple dot com>
- To: Jerry Quinn <jlquinn at optonline dot net>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Tue, 4 Feb 2003 10:40:22 -0800
- Subject: Re: Performance of copy algorithm
On Monday, February 3, 2003, at 10:06 PM, Jerry Quinn wrote:
A couple of observations. First, memcpy is very fast - the compiler
doesn't have enough optimization to squeeze the same performance out
of the straight loop. Second, we are taking a HUGE performance hit by
using memmove for this case. I figured memmove might be about
equivalent, but apparently not.
This is highly system dependent, and you don't say what OS you're
using for your test.
I know of one OS where memcpy is slower than a handwritten loop
(because memcpy on that system is stupid and always uses byte
instructions instead of word instructions), and I know of another OS
where memmove is very fast and memcpy is nothing but an alternate
name for it.
It's entirely possible that what you ought to be doing is improving
your OS's libc. memcpy and memmove ought to be carefully written
hand-optimized assembly code. Your tests might just show that on
your system nobody has given them the love and care that they