From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 21 11:29:30 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A78110656B4 for ; Mon, 21 Sep 2009 11:29:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id EDAE98FC2C for ; Mon, 21 Sep 2009 11:29:29 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n8LBTAvW045953 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 21 Sep 2009 14:29:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n8LBTA1X035556; Mon, 21 Sep 2009 14:29:10 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n8LBT9kX035555; Mon, 21 Sep 2009 14:29:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 21 Sep 2009 14:29:09 +0300 From: Kostik Belousov To: Igor Sysoev Message-ID: <20090921112909.GQ47688@deviant.kiev.zoral.com.ua> References: <20090917101526.GF57619@rambler-co.ru> <4AB2B7A1.5000601@delphij.net> <20090918074027.GI47688@deviant.kiev.zoral.com.ua> <20090921111245.GB23958@rambler-co.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2bjkoQU/J7v2vW91" Content-Disposition: inline In-Reply-To: <20090921111245.GB23958@rambler-co.ru> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean Cc: freebsd-hackers@freebsd.org, d@delphij.net Subject: Re: fcntl(F_RDAHEAD) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2009 11:29:30 -0000 --2bjkoQU/J7v2vW91 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 21, 2009 at 03:12:45PM +0400, Igor Sysoev wrote: > On Fri, Sep 18, 2009 at 10:40:27AM +0300, Kostik Belousov wrote: >=20 > > On Thu, Sep 17, 2009 at 03:26:41PM -0700, Xin LI wrote: > > > -----BEGIN PGP SIGNED MESSAGE----- > > > Hash: SHA1 > > >=20 > > > Hi, Igor, > > >=20 > > > Igor Sysoev wrote: > > > > Hi, > > > >=20 > > > > nginx-0.8.15 can use completely non-blocking sendfile() using SF_NO= DISKIO > > > > flag. When sendfile() returns EBUSY, nginx calls aio_read() to read= single > > > > byte. The first aio_read() preloads the first 128K part of a file i= n VM cache, > > > > however, all successive aio_read()s preload just 16K parts of the f= ile. > > > > This makes non-blocking sendfile() usage ineffective for files larg= er > > > > than 128K. > > > >=20 > > > > I've created a small patch for Darwin compatible F_RDAHEAD fcntl: > > > >=20 > > > > fcntl(fd, F_RDAHEAD, preload_size) > > > >=20 > > > > There is small incompatibilty: Darwin's fcntl allows just to enable= /disable > > > > read ahead, while the proposed patch allows to set exact preload si= ze. > > > >=20 > > > > Currently the preload size affects vn_read() code path only and doe= s not > > > > affect on sendfile() code path. However, it can be easy extended on > > > > sendfile() part too. The preload size is still limited by sysctl vf= s.read_max. > > > >=20 > > > > The patch is against FreeBSD 7.2 and was tested on FreeBSD 7.2-STAB= LE only. > > >=20 > > > I have ported this as a patch against -HEAD (should apply on 8.0-R but > > > it's too late for us to add a new feature) plus a manual page entry > > > documenting the feature. > > >=20 > > > I've used F_READAHEAD as the name, but reading the manual page, it lo= oks > > > like we can just use F_RDAHEAD since Darwin seems to just distinguish= 0 > > > and !=3D0 case so that programmers won't have to use #ifdef or someth= ing > > > else to get code working on different platform? > >=20 > > What I dislike about the patch is the new kernel-private flag that is > > eaten from the open(2) flags namespace. We do already have FHASLOCK, > > so far the only such flag. >=20 > We can change > int f_seqcount; > to > u_int f_seqcount; >=20 > and can use highest bit instead of O_READAHEAD: anyway f_seqcount is shif= ted > to 16 bits left. Or do the same trick as was done for FHASLOCK and override some flag that is not saved after open, see FMASK. Or split f_seqcount into two u_short fields, one for f_seqcount, second for f_kflag, and use the later for FHASLOCK and FREADAHEAD. [We are trying to not grow struct file unless absolutely neccessary]. --2bjkoQU/J7v2vW91 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkq3Y4UACgkQC3+MBN1Mb4gdtwCgkh3khwxHbgq8VOXljvlZajrN 6lAAn3OLf1STVZVjSh00jq4sIpJ1weQz =dVnX -----END PGP SIGNATURE----- --2bjkoQU/J7v2vW91--