Subject: Re: sendfile support in NetBSD
To: Perry E. Metzger <perry@piermont.com>
From: Thor Lancelot Simon <tls@rek.tjls.com>
List: netbsd-users
Date: 02/27/2007 19:09:58
On Tue, Feb 27, 2007 at 06:38:58PM -0500, Perry E. Metzger wrote:
> 
> Thor Lancelot Simon <tls@rek.tjls.com> writes:
> > On Tue, Feb 27, 2007 at 02:27:44PM +0200, Shadi Ammouri wrote:
> >> Hi,
> >> 
> >> Is there any equivalent for Linux's sendfile()/splice() system call.
> >
> > Because sendfile() blocks the calling process until the send is complete,
> > it offers no more benefit that the zero-copy TCP send that NetBSD already
> > has.
> 
> I think the question was "is there an equivalent of the Linux
> sendfile machinery". The answer is, no, NetBSD doesn't have it (though
> FreeBSD does).

I'm sorry, I strongly disagree with your answer.  The purpose of
sendfile() is to send a file out a socket without requiring it to
be copied from the application into the kernel.  But zero-copy TCP
send already achieves that, with no need for any new API.

Because it causes the calling process to block, sendfile() in fact is
no more efficient than a single write() of a mmap()ed region corresponding
to the entire file.  It is a duplicative and bogus API and I am glad it
is not present in NetBSD, where we provide a way to get the same or
better performance characteristics without requiring use of a nonstandard
and ill-conceived extension.

Thor