[LC++]file copying

Jack Lloyd lloyd at randombit.net
Sun Feb 15 15:46:02 UTC 2004


On Wed, 28 Jan 2004, Jan Pfeifer wrote:

> ps.: i did some measuring with the code, and it still takes 1.5 the time
> /bin/cp takes to copy. Anyone knows how /bin/cp does this faster ? I
> would guess it somehow manages to avoid a buffer copying, maybe using
> memory mapped files ...

Nope, according to strace, it does reads+writes. Memory mapped should be
faster, but I'm too lazy to try it out at the moment. Also I'm at work and
so, in theory, should be doing work.

Though even with mmap the data still goes kernel->process->kernel which is
not exactly ideal. It is sort of odd there is no kernel-level operation to
handle this on Unix. Avoiding moving all the data through the proccess'
address space would make this much faster.

-Jack




More information about the tuxCPProgramming mailing list