From owner-freebsd-arch Tue Apr 10 16:52:46 2001 Delivered-To: freebsd-arch@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id 0DD3137B423 for ; Tue, 10 Apr 2001 16:52:42 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id JAA10464 for ; Wed, 11 Apr 2001 09:52:38 +1000 (EST) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37645) with ESMTP id <01K29PDIRZBKS4N4IK@cim.alcatel.com.au> for freebsd-arch@freebsd.org; Wed, 11 Apr 2001 09:52:27 +1100 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.1/8.11.1) id f3ANqYH89314 for freebsd-arch@freebsd.org; Wed, 11 Apr 2001 09:52:34 +1000 (EST envelope-from jeremyp) Content-return: prohibited Date: Wed, 11 Apr 2001 09:52:33 +1000 From: Peter Jeremy Subject: mmap(2) vs read(2)/write(2) To: freebsd-arch@freebsd.org Mail-Followup-To: freebsd-arch@freebsd.org Message-id: <20010411095233.P66243@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG It is my understanding that it is more efficient to access a file via mmap rather than read/write, because the former needs one less memory-memory copy. Currently stdio uses read/write, but it would seem trivial to change at least the read operations to use mmap. For an mmap'd file, FILE->_p would point to the mmap'd region and FILE->_r would represent the number of remaining valid bytes. FILE->_bf could be used to cache the mmap'd region. My reading of ISO-C is that the mode argument to fopen(3) can include arbitrary, implementation-defined enhancements - which would allow an application to select read/write or mmap and maybe allow the application to advise its intended behaviour (ala madvise(2)). The behaviour of `portable' applications could be controlled via /etc/stdio.conf and STDIO_CONF in the same manner as malloc(3). Does this sound like a worthwhile enhancement? Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message