From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 12 14:38:35 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 83AE316A41F for ; Mon, 12 Dec 2005 14:38:35 +0000 (GMT) (envelope-from silby@silby.com) Received: from relay01.pair.com (relay01.pair.com [209.68.5.15]) by mx1.FreeBSD.org (Postfix) with SMTP id A6E7843D6A for ; Mon, 12 Dec 2005 14:38:34 +0000 (GMT) (envelope-from silby@silby.com) Received: (qmail 23370 invoked from network); 12 Dec 2005 14:38:33 -0000 Received: from unknown (HELO localhost) (unknown) by unknown with SMTP; 12 Dec 2005 14:38:33 -0000 X-pair-Authenticated: 209.68.2.70 Date: Mon, 12 Dec 2005 08:38:35 -0600 (CST) From: Mike Silbersack To: Cedric Tabary In-Reply-To: <20051212083930.GC91837@efrei.fr> Message-ID: <20051212083537.T78724@odysseus.silby.com> References: <20051212083930.GC91837@efrei.fr> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-379007335-1134398315=:78724" Cc: freebsd-hackers@freebsd.org Subject: Re: mmap() sendfile() 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, 12 Dec 2005 14:38:35 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-379007335-1134398315=:78724 Content-Type: TEXT/PLAIN; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 12 Dec 2005, Cedric Tabary wrote: > If it is true, doing a sendfile() on some very big files (even if not > keeping the descriptor open after) will kill the cache ? > > Please help me to understand why this patch ? and the difference between > sendfile() and mmap() at the memory or cache level.. > > C=E9dric My memory escapes me on all the details, but there were two potential=20 reasons not to use sendfile with 4.x that no longer apply in 5.x and=20 above: 1. Sendfile used to send small files inefficiently, sending the http=20 headers in one packet and the data in another. I fixed this in 5.x. 2. Alan Cox improved the memory efficiency of sendfile greatly, it now=20 uses a single kernel buffer for all copies of the same block of the same=20 file, whereas the old implementation made an in-kernel copy of each block,= =20 making it no more memory efficient than using mbufs. So, if there was a reason to not use sendfile under 4.x, it's probably not= =20 true anymore. Someone sent me a patch to thttpd which made it more efficient on FreeBSD= =20 a looooooong time ago, I don't recall what changes he had made. Mike "Silby" Silbersack --0-379007335-1134398315=:78724--