From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 3 20:17:14 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0473C414; Thu, 3 Apr 2014 20:17:14 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE76AA45; Thu, 3 Apr 2014 20:17:13 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AA5D3B97D; Thu, 3 Apr 2014 16:17:12 -0400 (EDT) From: John Baldwin To: Dmitry Sivachenko Subject: Re: madvise() vs posix_fadvise() Date: Thu, 3 Apr 2014 15:27:59 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20130906; KDE/4.5.5; amd64; ; ) References: <201404031230.40380.jhb@freebsd.org> <2CB392D0-5198-41EB-8191-8B02FE432334@gmail.com> In-Reply-To: <2CB392D0-5198-41EB-8191-8B02FE432334@gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Message-Id: <201404031527.59901.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 03 Apr 2014 16:17:12 -0400 (EDT) Cc: freebsd-hackers@freebsd.org, Ian Lepore , Trond =?iso-8859-1?q?Endrest=F8l?= X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2014 20:17:14 -0000 On Thursday, April 03, 2014 3:10:49 pm Dmitry Sivachenko wrote: >=20 > On 03 =C1=D0=D2. 2014 =C7., at 20:30, John Baldwin wrot= e: >=20 > >=20 > > The latter. It's sort of like a lazy O_DIRECT. Each time you call wri= te(2), > > it tries to move any clean pages from your current sequentially written > > stream from inactive to cache, so the pages won't move until a subseque= nt > > write(2) after bufdaemon or the syncer actually forces them to be writt= en. > > Unfortunately, it is currently implemented by doing an internal > > FADV_DONTNEED after each read() or write(). It would be better if it w= as > > implemented as a callback when buffers are completed. >=20 >=20 >=20 > Sounds like FADV_NOREUSE should be befeficial for any log-writing program? > (syslogd, apache, nginx, .....) Well, it depends. If you plan on reading the log files, then using NOREUSE can potentially make that more expensive as the logs are more likely to be out of RAM when you go to read them (even if you have free memory, mostly because "cache" isn't perfect, at least in my experience). OTOH, pagedaemon (a part of the VM system) should generally pick the log pages to evict when needed (and I believe it might do a better job of that in 10 than it did previously). I think if you know that the log files are kicking more useful things out of RAM and you don't generally plan on reading them (note that things like compressing them with gzip counts as reading), then FADV_NOREUSE can work fine. =2D-=20 John Baldwin