Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 2003 12:25:43 +0400 (MSD)
From:      Igor Sysoev <is@rambler-co.ru>
To:        Terry Lambert <tlambert2@mindspring.com>
Cc:        arch@freebsd.org
Subject:   Re: sendfile(2) SF_NOPUSH flag proposal
Message-ID:  <Pine.BSF.4.21.0305271157480.46491-100000@is>
In-Reply-To: <3ED2AF18.F5EB4FA5@mindspring.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 26 May 2003, Terry Lambert wrote:

> Igor Sysoev wrote:
> > sendfile(2) now has two drawbacks:
> 
> Only two?  ;^).

No, I know some other drawbacks but I do not see now the ways to resolve them.

> > So here is a proposal.  We can introduce a sendfile(2) flag, i.e. SF_NOPUSH
> > that will turn TF_NOPUSH on before the sending and turn it off just
> > before return. It allows to save two syscalls on each sendfile() call
> > and it's especially useful with non-blocking sockets - they can cause many
> > sendfile() calls.
> 
> I don't see this as being terrifically useful; small files
> should probably just be mapped and written; the copy expense
> is still there for the headers and trailers, no matter what,
> and the file size itself is very small overhead, relatively
> speaking, for files small enough for this to be an issue.

FreeBSD 4.x has no zero_copy(9) so mmap()ed files would be copied.
sendfile() allows to avoid this copy.

By the way what do you call by small files ? 4K, 30K or 100K ?

> I also think your headers and trailers are very small, if
> they are fitting with the file contents in a single packet.
> I think this is atypical.

If I ask Google:
----
HEAD /images/hp0.gif HTTP/1.0
Host: www.google.com

----
it will return me 230 bytes:
----
HTTP/1.0 200 OK
Connection: Keep-Alive
Date: Tue, 27 May 2003 08:10:59 GMT
Content-Type: image/gif
Last-Modified: Tue, 22 Apr 2003 22:18:49 GMT
Expires: Sun, 17 Jan 2038 19:14:07 GMT
Content-length: 4277
Server: GWS/2.0

----
and it's the typical HTTP header of the static response (that can be handled
with sendfile()).

> On the other hand, if you want to add a flag for this, I say
> "knock yourself out" -- go ahead and add the flag; it's not
> really going to benefit you that much, but it's not going to
> really hurt any of the rest of us either, so there's really
> no reason to make you not do it.  8-).
> 
> BTW: if you go ahead with this, you should verify that it
> also works for the trailers, etc., and you should probably
> skip it if you headers > transmit queue depth, or file size
> > transmit queue depth, or trailers > transmit queue depth.

Currently sendfile() can send the file in not full packets even
file is bigger then the transmit queue depth. It can send
it in 2 x 1460 + 1176 or 5 x 1460 + 892 packets.


Igor Sysoev
http://sysoev.ru/en/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0305271157480.46491-100000>