Date: Tue, 10 Apr 2001 17:15:22 -0700 From: Alfred Perlstein <bright@wintelcom.net> To: Peter Jeremy <peter.jeremy@alcatel.com.au> Cc: freebsd-arch@FreeBSD.ORG Subject: Re: mmap(2) vs read(2)/write(2) Message-ID: <20010410171522.H15938@fw.wintelcom.net> In-Reply-To: <20010411095233.P66243@gsmx07.alcatel.com.au>; from peter.jeremy@alcatel.com.au on Wed, Apr 11, 2001 at 09:52:33AM %2B1000 References: <20010411095233.P66243@gsmx07.alcatel.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
* Peter Jeremy <peter.jeremy@alcatel.com.au> [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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010410171522.H15938>