From owner-freebsd-arch Tue Apr 10 17:15:29 2001 Delivered-To: freebsd-arch@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 6733137B422 for ; Tue, 10 Apr 2001 17:15:26 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f3B0FMC11867; Tue, 10 Apr 2001 17:15:22 -0700 (PDT) Date: Tue, 10 Apr 2001 17:15:22 -0700 From: Alfred Perlstein To: Peter Jeremy Cc: freebsd-arch@FreeBSD.ORG Subject: Re: mmap(2) vs read(2)/write(2) Message-ID: <20010410171522.H15938@fw.wintelcom.net> References: <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 In-Reply-To: <20010411095233.P66243@gsmx07.alcatel.com.au>; from peter.jeremy@alcatel.com.au on Wed, Apr 11, 2001 at 09:52:33AM +1000 X-all-your-base: are belong to us. Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Peter Jeremy [010410 16:52] wrote: > 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, the stdio would still have to copy the data into the user supplied buffer, sure you would save a context switch, but you'd have the vm overhead of constantly mapping pages in and out. I don't think it's worth it, but it shouldn't discourage you from trying and posting results. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] Represent yourself, show up at BABUG http://www.babug.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message