Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2006 21:35:01 -0700
From:      "David G. Lawrence" <dg@dglawrence.com>
To:        Mikhail Teterin <mi+mx@aldan.algebra.com>
Cc:        net@freebsd.org
Subject:   Re: complement to sendfile()?
Message-ID:  <20060720043501.GG924@tnn.dglawrence.com>
In-Reply-To: <200607192316.56157.mi%2Bmx@aldan.algebra.com>
References:  <200607192230.14939.mi%2Bmx@aldan.algebra.com> <20060720025003.GF924@tnn.dglawrence.com> <200607192316.56157.mi%2Bmx@aldan.algebra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> ?????? 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060720043501.GG924>