On Wed, 24 Jul 2002, Tom Lane wrote:
> Curt Sampson <cjs@cynic.net> writes:
> > But this would only cost us more syscalls, which are relatively
> > inexpensive (compared to things like memory copies) anyway.
>
> Run that by me again?
>
> I'd take memcpy over a kernel call any day. If you want to assert
> that the latter is cheaper, you'd better supply some evidence.
So on my Athlon system:
ironic $ /usr/pkg/bin/lmbench/mhz
1533 MHz, 0.65 nanosec clock
ironic $ /usr/pkg/bin/lmbench/lat_syscall null
Simple syscall: 0.2026 microseconds
ironic $ /usr/pkg/bin/lmbench/bw_mem 32m bcopy
33.55 352.69
352.69 MB/sec works out to about 370 bytes per microsecond. Thus,
copying an 8K page should take a bit over 22 microseconds, enough
time for the overhead of 110 syscalls.
ironic $ /usr/pkg/bin/lmbench/bw_mem 64k bcopy
0.065536 2038.58
Even entirely in L1 cache, I still get only about 2138 bytes per
microsecond, thus taking almost 4 microseconds to copy a page, the same
as the overhead for 8 syscalls.
On older systems, such as a P5-133, a syscall was about 4 microseconds,
and bcopy was 42 MB/sec, or 44 bytes per microsecond. Thus a page copy
was 186 microseconds, enough time for the overhead of only 46 syscalls.
I expect that the long, long trend of CPU speed growing faster than
memory speed will continue, and memory copies will become ever more
expensive than more CPU-boun activity such as syscalls.
All this aside, remember that when you copy a block under the
current system, you're doing it with read() or write(), and thus
paying the syscall overhead anyway.
cjs
--
Curt Sampson <cjs@cynic.net> +81 90 7737 2974 http://www.netbsd.org
Don't you know, in this new Dark Age, we're all light. --XTC