From owner-freebsd-arch@FreeBSD.ORG Tue May 27 13:05:27 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DBE7A37B401 for ; Tue, 27 May 2003 13:05:27 -0700 (PDT) Received: from park.rambler.ru (park.rambler.ru [81.19.64.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 647A543F85 for ; Tue, 27 May 2003 13:05:26 -0700 (PDT) (envelope-from is@rambler-co.ru) Received: from is.park.rambler.ru (is.park.rambler.ru [81.19.64.102]) by park.rambler.ru (8.12.6/8.12.6) with ESMTP id h4RK5DmF025579; Wed, 28 May 2003 00:05:13 +0400 (MSD) Date: Wed, 28 May 2003 00:05:13 +0400 (MSD) From: Igor Sysoev X-Sender: is@is To: Matthew Dillon In-Reply-To: <200305271801.h4RI12Qr066864@apollo.backplane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: arch@freebsd.org Subject: Re: sendfile(2) SF_NOPUSH flag proposal X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 May 2003 20:05:28 -0000 On Tue, 27 May 2003, Matthew Dillon wrote: > But considering the fairly high syscall overhead of sendfile() verses the > 1uS or so it takes to do a setsockopt(), implementing additional > flags in the sendfile() API to work around sendfile()'s inefficient > implementation of the header sending code SOLELY to avoid the additional > syscalls is not a good enough reason to change the API. It would just > be adding one hack on top of another with the side effect of the new > hack being visible in the API. This is bad. > > This (minor) problem *should* be solved by fixing the sendfile() > implementation itself. > It may well be that a reasonable solution would be to have sendfile() > itself set TCP_NOPUSH internally to wrap the header sending writev() > and the first data packet, then restore the previous state after > queueing the first data packet. That would still be a hack, but at least > it would be one that is not being made visible in the API. TCP_NOPUSH is required not only to coalesce the header and the first file part or the last file part and the trailer. It's also required to avoid the partially filled file packets. As I said already the file pages can be sent in 2x1460+1176 or 5x1460+892 packets. The implicit setting TF_NOPUSH in sendfile() and restoring it before return would not resolve completely partially filled file packets in the case of non-blocking socket. > Visible changes in APIs create porting headaches between UNIXes and > should be avoided whenever possible. I agree with portability issues but sendfile() is already very non-portable interface. sendfile() has different prototypes and functionality in all unicies. For example, Linux's sendfile() can not send headers or trailers, HP/UX's sendfile() allows to send only one header and one trailer (i.e. they are not iovec's), Solaris's sendfilev() allows to send combination of the several files and iovecs like WinXP's TransmitPackets(). Igor Sysoev http://sysoev.ru/en/