Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Nov 2003 10:26:14 -0800
From:      John-Mark Gurney <gurney_j@efn.org>
To:        Igor Sysoev <is@rambler-co.ru>
Cc:        Alan Cox <alc@cs.rice.edu>
Subject:   Re: Update: Debox sendfile modifications
Message-ID:  <20031109182614.GH558@funkthat.com>
In-Reply-To: <Pine.BSF.4.21.0311091515470.18994-100000@is.park.rambler.ru>
References:  <20031109033026.GF558@funkthat.com> <Pine.BSF.4.21.0311091515470.18994-100000@is.park.rambler.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Igor Sysoev wrote this message on Sun, Nov 09, 2003 at 15:16 +0300:
> On Sat, 8 Nov 2003, John-Mark Gurney wrote:
> 
> > Igor Sysoev wrote this message on Wed, Nov 05, 2003 at 12:31 +0300:
> > > I think it can done in the following way - a socket should have flag
> > > that says that sendfile() had started the reading a page.
> > 
> > layer violation...
> 
> I do not think that it's layer violation. sendfile() works with
> descriptor so it should know its state. It should know wheather
> descriptor is non-blocking or has it enough buffer space.

Ugh, yes, you are correct.. it is limited to sockets:
        if ((error = fgetsock(td, uap->s, &so, NULL)) != 0)
                goto done;
        if (so->so_type != SOCK_STREAM) {

:(

[...]

> > If you made this a fd transparent operation then I would agree with
> > it.
> 
> The current sendfile() implementation works with sockets only.
> Well, I agree that such sendfile() implementation is a hack.
> Nowever this implementation is very usefull in the real world -
> it allows to minimize a data copy in http and ftp servers.
> 
> I just could not figure to myself where can be usefull the
> high perfomance sendfile() to a pipe.

It's not so much of how, but optimizing for the general case, not
the specific case.  I was using pipes as an example, what about for
coping one fd to another?  Right now cp will try to mmap a 16meg buffer,
and use that, if it fails, it falls back to a read/write loop.. why
not do something like copyfd that does it more optimally?

> I think that it's better to leave sendfile() as a sending to a socket
> only hack. I believe that any sendfile() generalization (e.g. sending
> data from a socket to a file) is useless.

oh? why do you think that is useless?  What about all the applications
like ftp clients, and wget/fetch/curl that do it on a regular basis?

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



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