complement to sendfile()?
Mikhail Teterin
mi+mx at aldan.algebra.com
Thu Jul 20 03:17:14 UTC 2006
середа 19 липень 2006 22:50, David G. Lawrence написав:
> sendfile() could be extended to allow arbitrary file descriptor types as
> the source and destination, but the zero-copy nature of it can only work
> in the file to socket direction. This is because network buffers can be
> made out of filesystem buffers (file->network direction), but for the
> network to file direction network packets arrive non-deterministically.
> With the right network hardware it would in theory be possible to have the
> TCP code run on the network card and it could DMA the TCP stream directly
> into file buffers. If pigs had wings, they could fly. :-)
Ok, so zero-copy may not work, but one-copy would still be better, than the
usual two-copy.
Am I right? With the usual read/write method, data is read from the network
card to kernel's buffers, from there to the application buffer, and from
there to the filesystem. That's two copies, no?
Having mmap-ed the output file, I could read from the socket directly into the
mmap-returned "buffer", but writing via. mmap appears to be implemented
pessimally in FreeBSD and breaks horrendously if the output file happens to
be accessed via NFS.
Thanks!
-mi
More information about the freebsd-net
mailing list