Re: complement to sendfile()?



?????? 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?

Yes, you are right. A few other cool things that could be done with
sendfile include:

o Full duplex zero-copy socket to socket sends. This could be used on (e.g
Squid) proxy servers, for example, to connect two (inside/outside) TCP
streams. Plus an "ASYNC" flag to make it all happen in the background
inside the kernel (returning immediately to the proxy application).

o An "APPEND" flag that allows sendfile to block at the end of file, waiting
for more data to be written to it (as long as someone has the file open
for append). This would be very useful in some real-time audio/video
streaming applications (like the one I'm working on right now :-)).

-DG

David G. Lawrence
President
Download Technologies, Inc. - http://www.downloadtech.com - (866) 399 8500
The FreeBSD Project - http://www.freebsd.org
Pave the road of life with opportunities.
_______________________________________________
freebsd-net@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: How relevant is "Automatic TCP Window Tuning" in Networking Applications ?
    ... and Bandwidth is the bandwidth of the network. ... For a local network of 100 MBits/sec, a really awful RTT is around 1 ... the default size of the buffers is 8K. ... I don't know what Apache or FTP servers do. ...
    (microsoft.public.win32.programmer.networks)
  • Re: complement to sendfile()?
    ... but the zero-copy nature of it can only work ... in the file to socket direction. ... This is because network buffers can be ... network to file direction network packets arrive non-deterministically. ...
    (freebsd-net)
  • Netbackup Buffer Settings on RHEL 5
    ... I was wondering if anyone has tweaked netbackup buffers for LTO2 ... class backup server running RHEL 5 64-bit and NBU 6.5. ... poor network backup performance (using both the NBU client and by ...
    (RedHat)
  • Re: Design Advice
    ... > dump of all the buffers may overload it or the network. ... In the case of a DB / Master Server going off-line, ... are no hard-limits regarding time of data collection (other than common ...
    (comp.arch.embedded)
  • Re: Network buffering question
    ... I hope this is the best newsgroup for this topic. ... I am working on some network code right now. ... single packet, because you might actually read past the packet you are ... buffers or circular buffers? ...
    (comp.programming)