Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Dec 1995 16:51:31 +0100
From:      Didier Derny <didier@aida.org>
To:        David Hovemeyer <daveho@infocom.com>
Cc:        <hackers@FreeBSD.ORG>, David Hovemeyer <daveho@infocom.com>
Subject:   RE: mmap and memory utilization
Message-ID:  <XFMail.951223165131.didier@aida>
In-Reply-To: <Pine.BSF.3.91.951216123927.19249G-100000@infocom.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On 16-Dec-95 David Hovemeyer wrote:
>>Howdy all,
>
>I am writing a program that needs to do a lot of character at
>a time reading through regular files, both forwards and backwards.
>I decided to use mmap(2) rather than read(2) to implement this.
>My reasoning is that it is easier to do random access in memory
>than in a file.  Also, I imagine that calling read(2) for reading
>single characters is inefficient in terms of system call overhead.
>I could use iostreams (it's a C++ program) to get buffering of
>reads, but iostreams are big and hairy, and still more awkward
>to use than memory for what I want to do.
>
>What I am wondering is
>
>	What is the impact of mmap'ing a large file and then
>	scanning linearly through it?
>
>Currently I am thinking of mmap'ing the entire file; if the file is
>approximately as large as physical memory, will this cause excessive
>paging?  (I am assuming an infinite amount of virtual memory,
>but a limited amount of physical memory.)  Will the program degrade
>the performance of other programs which are running?  Would the mmap
>be likely to fail?
>
>In most cases I expect the mmap'ed file to be small (< 16K), but
>I want the program to be a "good citizen" under extreme conditions.
>I'm pretty clueless about the details of virtual memory and how
>it is implemented in FreeBSD.
>
>Hmm, I just noticed the madvise(2) man page: is this what I need
>to use?  Maybe I could say MADV_DONTNEED to pages scanned past,
>and MADV_WILLNEED to pages about to be accessed?
>
>Any thoughts appreciated.
>
>Dave
>--
>David Hovemeyer    | aclawisaclawandnobodyhasseenatalking | http://infoco
>daveho@infocom.com | clawunlessthatclawisthefamousMr.Klaw | m.com/~daveho
>

I usualy map 32 mb file almost everyday without any problem. I only have 16Mb of
memory. I'm using strstr inside the mapped file to find substring. 
In fact  I map 2 32 mb files at the same time

-- 12/18/95 20:01:22
Didier Derny            | My computer is Microsoft Free... 
didier@aida.org         | Private FreeBSD 2.1-STABLE site.






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.951223165131.didier>