From owner-freebsd-hackers Mon Dec 18 04:55:40 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id EAA24603 for hackers-outgoing; Mon, 18 Dec 1995 04:55:40 -0800 (PST) Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id EAA24183 for ; Mon, 18 Dec 1995 04:43:09 -0800 (PST) Received: from caramba.cs.tu-berlin.de (wosch@caramba.cs.tu-berlin.de [130.149.17.12]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id NAA00811; Mon, 18 Dec 1995 13:12:59 +0100 From: Wolfram Schneider Received: (wosch@localhost) by caramba.cs.tu-berlin.de (8.6.12/8.6.9) id NAA23098; Mon, 18 Dec 1995 13:12:54 +0100 Date: Mon, 18 Dec 1995 13:12:54 +0100 Message-Id: <199512181212.NAA23098@caramba.cs.tu-berlin.de> To: David Hovemeyer Cc: hackers@FreeBSD.ORG Subject: mmap and memory utilization In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-hackers@FreeBSD.ORG Precedence: bulk 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