From owner-freebsd-current@FreeBSD.ORG Wed Jun 23 03:59:14 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F337C16A4CE; Wed, 23 Jun 2004 03:59:13 +0000 (GMT) Received: from corbulon.video-collage.com (corbulon.video-collage.com [64.35.99.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 61BEA43D5E; Wed, 23 Jun 2004 03:59:13 +0000 (GMT) (envelope-from mi@vaio.virtual-estates.net) Received: from vaio.virtual-estates.net (aldan.algebra.com [216.254.65.224]) i5N3wsCX080675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Jun 2004 23:58:56 -0400 (EDT) (envelope-from mi@vaio.virtual-estates.net) Received: from vaio.virtual-estates.net (localhost [127.0.0.1]) i5N3wREd000957; Tue, 22 Jun 2004 23:58:28 -0400 (EDT) (envelope-from mi@vaio.virtual-estates.net) Received: from localhost (localhost [[UNIX: localhost]]) i5N3wOHB000956; Tue, 22 Jun 2004 23:58:24 -0400 (EDT) (envelope-from mi) From: "Mikhail T." To: Peter Wemm Date: Tue, 22 Jun 2004 23:58:24 -0400 User-Agent: KMail/1.6.2 References: <200406220108.31366@aldan> <200406222027.30702.peter@wemm.org> In-Reply-To: <200406222027.30702.peter@wemm.org> X-Face: %UW#n0|w>ydeGt/b@1-.UFP=K^~-:0f#O:D7whJ5G_<5143Bb3kOIs9XpX+"V+~$adGP:J|SLieM31VIhqXeLBli"<=?koi8-u?q?kcG=5EEOVihy+z3/UR=7B6SCQ=0A?= MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="koi8-u" Content-Transfer-Encoding: quoted-printable Message-Id: <200406222358.24573@Misha> X-Virus-Scanned: clamd / ClamAV version devel-20040615, clamav-milter version 0.73a on corbulon.video-collage.com X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.39 X-Mailman-Approved-At: Wed, 23 Jun 2004 11:54:04 +0000 cc: current@freebsd.org cc: questions@freebsd.org cc: Mikhail Teterin cc: freebsd-current@freebsd.org cc: Julian Elischer cc: Mikhail Teterin Subject: Re: read vs. mmap (or io vs. page faults) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2004 03:59:14 -0000 =D7=A6=D7=D4=CF=D2=CF=CB 22 =DE=C5=D2=D7=C5=CE=D8 2004 23:27, Peter Wemm, = =F7=C9 =CE=C1=D0=C9=D3=C1=CC=C9: =3D On Monday 21 June 2004 10:08 pm, Mikhail Teterin wrote: =3D The amount of "work" for the kernel to do a read() and a high-speed =3D memory copy is much less than the cost of taking a page fault, running =3D a whole bunch of really really nasty code in the vm system, repairing =3D the damage from the page fault, updating the process paging state and =3D restarting the instruction. Does the code _have_ to be "really really nasty", or it just _happened_ to be that way for historical reasons -- like this being a very complex issue, and, once it worked, no one really wanted to mess with it? =3D The numbers you're posting are a simple reflection of the fact that =3D the read syscall path has fewer (and less expensive) instructions to =3D execute compared to the mmap fault paths. Why, then, is the total number of CPU seconds (kernel+user) favorable towards mmap on CPU bound machines and about the same on IO bound? May be, because all that CPU work, you are describing, is also much faster on the modern CPUs? =3D Some operating systems implemented read(2) as an internal in-kernel =3D mmap/fault/copy/unmap. Naturally, that made mmap look fast compared to =3D read, at the time. But that isn't how it is implemented in FreeBSD. =3D mmap is more valuable as a programmer convenience these days. I figured :-( It is very convenient. As such, it should be wider used (because it leads to cleaner code), but that wouldn't come until it also offers the performance comparable to the less clean method(s)... Yours, -mi