From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 21 11:12:47 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 739B51065695 for ; Mon, 21 Sep 2009 11:12:47 +0000 (UTC) (envelope-from is@rambler-co.ru) Received: from mailrelay1.rambler.ru (mailrelay1.rambler.ru [81.19.66.239]) by mx1.freebsd.org (Postfix) with ESMTP id 0CB458FC17 for ; Mon, 21 Sep 2009 11:12:46 +0000 (UTC) Received: from kas30pipe.localhost (localhost [127.0.0.1]) by mailrelay1.rambler.ru (Postfix) with ESMTP id 0C159130C80; Mon, 21 Sep 2009 15:12:46 +0400 (MSD) Received: from localhost (www290.rambler.ru [10.9.0.148]) by mailrelay1.rambler.ru (Postfix) with ESMTP id A9C30130C68; Mon, 21 Sep 2009 15:12:45 +0400 (MSD) Date: Mon, 21 Sep 2009 15:12:45 +0400 From: Igor Sysoev To: Kostik Belousov Message-ID: <20090921111245.GB23958@rambler-co.ru> References: <20090917101526.GF57619@rambler-co.ru> <4AB2B7A1.5000601@delphij.net> <20090918074027.GI47688@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20090918074027.GI47688@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.20 (2009-06-14) X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.33/RELEASE, bases: 02092009 #2738642, status: clean X-SpamTest-Envelope-From: is@rambler-co.ru X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 9536 [Sen 02 2009] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Method: white ip list X-SpamTest-Rate: 0 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0284], KAS30/Release 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:12:47 -0000 On Fri, Sep 18, 2009 at 10:40:27AM +0300, Kostik Belousov wrote: > On Thu, Sep 17, 2009 at 03:26:41PM -0700, Xin LI wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > Hi, Igor, > > > > Igor Sysoev wrote: > > > Hi, > > > > > > nginx-0.8.15 can use completely non-blocking sendfile() using SF_NODISKIO > > > 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 in VM cache, > > > however, all successive aio_read()s preload just 16K parts of the file. > > > This makes non-blocking sendfile() usage ineffective for files larger > > > than 128K. > > > > > > I've created a small patch for Darwin compatible F_RDAHEAD fcntl: > > > > > > fcntl(fd, F_RDAHEAD, preload_size) > > > > > > There is small incompatibilty: Darwin's fcntl allows just to enable/disable > > > read ahead, while the proposed patch allows to set exact preload size. > > > > > > Currently the preload size affects vn_read() code path only and does not > > > affect on sendfile() code path. However, it can be easy extended on > > > sendfile() part too. The preload size is still limited by sysctl vfs.read_max. > > > > > > The patch is against FreeBSD 7.2 and was tested on FreeBSD 7.2-STABLE only. > > > > 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. > > > > I've used F_READAHEAD as the name, but reading the manual page, it looks > > like we can just use F_RDAHEAD since Darwin seems to just distinguish 0 > > and !=0 case so that programmers won't have to use #ifdef or something > > else to get code working on different platform? > > 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. We can change int f_seqcount; to u_int f_seqcount; and can use highest bit instead of O_READAHEAD: anyway f_seqcount is shifted to 16 bits left. -- Igor Sysoev http://sysoev.ru/en/