Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Dec 1995 13:12:54 +0100
From:      Wolfram Schneider <wosch@cs.tu-berlin.de>
To:        David Hovemeyer <daveho@infocom.com>
Cc:        hackers@FreeBSD.ORG
Subject:   mmap and memory utilization
Message-ID:  <199512181212.NAA23098@caramba.cs.tu-berlin.de>
In-Reply-To: <Pine.BSF.3.91.951216123927.19249G-100000@infocom.com>
References:  <Pine.BSF.3.91.951216123927.19249G-100000@infocom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
David Hovemeyer writes:

>What I am wondering is
>
>	What is the impact of mmap'ing a large file and then
>	scanning linearly through it?

mmap is your friend if the file size is less than 1/2 of
memory and if you read the file more than once.


Example: locate(1) with mmap and without mmap (fopen, getc)


$ ls -l find.codes 
-rw-rw-r--  1 wosch    14549501 Dec 18 06:45 find.codes

$ uname -s -r
SunOS 5.4
(FreeBSD mmap seems a little bit slower than solaris mmap
 or FreeBSD getc is faster than solaris getc :-)


o with mmap

$ time ../../bin/sol2/blocate -m -d find.codes woscH

real        5.5
user        3.1
sys         0.3

bash$ time ../../bin/sol2/blocate -m -d find.codes woscH

real        3.3
user        3.0
sys         0.1
bash$ time ../../bin/sol2/blocate -m -d find.codes woscH

real        3.4
user        3.0
sys         0.1


o without mmap


$ time ../../bin/sol2/blocate  -d find.codes woscH

real        6.7
user        4.9
sys         1.1
bash$ time ../../bin/sol2/blocate  -d find.codes woscH

real        7.0
user        4.9
sys         0.9
bash$ time ../../bin/sol2/blocate  -d find.codes woscH

real        6.6
user        5.0
sys         0.9



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