sendfile(2) SF_NOPUSH flag proposal
From: Igor Sysoev (is_at_rambler-co.ru)
Date: 05/26/03
- Previous message: Alexey Dokuchaev: "Re: scheduler determination"
- Next in thread: Peter Jeremy: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Reply: Peter Jeremy: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Reply: Terry Lambert: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Maybe reply: Bill Fenner: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Maybe reply: Bill Fenner: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 26 May 2003 21:41:50 +0400 (MSD) To: arch@freebsd.org
sendfile(2) now has two drawbacks:
1) it always sends the header, the file and the trailer in the separate
packets even their sizes allow to place all them in one packet.
For example the typical HTTP response header is less then an ethernet
packet and sendfile() sends it in first small packet.
2) often enough it sends 4K page in three packets: 1460, 1460 and 1176 bytes.
When I turn TCP_NOPUSH on just before sendfile() then it sends the header
and the first part of the file in one 1460 bytes packet.
Besides it sends file pages in the full ethernet 1460 bytes packets.
When sendfile() completed or returned EAGAIN (I use non-blocking sockets)
I turn TCP_NOPUSH off and the remaining file part is flushed to client.
Without turing off the remaining file part is delayed for 5 seconds.
Surprisingly that the turning TCP_NOPUSH off flushes the file part (I did not
try the trailer) on FreeBSD 4.2 and 4.3 without src/sys/netinet/tcp_usrreq.c
fixes 1.53 and 1.51.2.11.
I looked in src/sys/netinet/tcp_usrreq.c to learn how
to turn TCP_NOPUSH on/off. It's seems it's as simple as:
struct inpcb *inp;
struct tcpcb *tp;
inp = sotoinpcb(so);
tp = intotcpcb(inp);
turn on:
tp->t_flags |= TF_NOPUSH;
turn off:
tp->t_flags &= ~TF_NOPUSH;
error = tcp_output(tp);
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.
Igor Sysoev
http://sysoev.ru/en/
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
- Previous message: Alexey Dokuchaev: "Re: scheduler determination"
- Next in thread: Peter Jeremy: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Reply: Peter Jeremy: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Reply: Terry Lambert: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Maybe reply: Bill Fenner: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Maybe reply: Bill Fenner: "Re: sendfile(2) SF_NOPUSH flag proposal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|