From owner-freebsd-questions@FreeBSD.ORG Mon Jun 21 22:26:51 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0B1FD16A4CE; Mon, 21 Jun 2004 22:26:51 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98DBE43D39; Mon, 21 Jun 2004 22:26:50 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.10/8.12.10) id i5LMQW8W018954; Mon, 21 Jun 2004 17:26:32 -0500 (CDT) (envelope-from dan) Date: Mon, 21 Jun 2004 17:26:32 -0500 From: Dan Nelson To: Mikhail Teterin Message-ID: <20040621222631.GC86471@dan.emsphone.com> References: <200406211057.31103@aldan> <200406211952.i5LJqWSl035702@apollo.backplane.com> <200406211810.03629@misha-mx.virtual-estates.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200406211810.03629@misha-mx.virtual-estates.net> X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: Matthew Dillon cc: questions@freebsd.org cc: Julian Elischer cc: Mikhail Teterin cc: current@freebsd.org Subject: Re: read vs. mmap (or io vs. page faults) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2004 22:26:51 -0000 In the last episode (Jun 21), Mikhail Teterin said: > > Both read and mmap have a read-ahead heuristic. The heuristic > > works. In fact, the mmap heuristic is so smart it can read-behind > > as well as read-ahead if it detects a backwards scan. > > Evidently, read's heuristics are better. At least, for this task. > I'm, actually, surprised, they are _different_ at all. [...] > That other OSes have similar shortcomings simply gives us some > breathing room from an advocacy point of view. I hope, my rhetoric > will burn an itch in someone capable of addressing it technically :-) > > > The heuristic does not try to read megabytes and megabytes ahead, > > however... > > Neither does the read-handling. I think part of the problem is that it's just clustering reads instead of making sure the next N blocks of data are prefetched. So you may ask for 8k, but the system will fetch the next 64k of data. Problem is the system does nothing until you read the next 8k past the 64k alreqady read in, then it jumps up and grabs the next 64k. You're still waiting on I/O every 8th read. Ideally it would do an async fetch of a 8k block (64k ahead of the current read) every time you read a block. It should be a lot easier for read to do this, since the kernel is getting a steady stream of syscalls. Once a 64k chunk of mmapped address space is pulled in, the system isn't notified until the next page fault. (or am I misunderstanding how readahead is implemented on mmapped data?) -- Dan Nelson dnelson@allantgroup.com