Re: [HACKERS] Safe/Fast I/O ... - Mailing list pgsql-hackers

From Michal Mosiewicz
Subject Re: [HACKERS] Safe/Fast I/O ...
Date
Msg-id 35316901.D14CD5A3@interdata.com.pl
Whole thread Raw
In response to Re: [HACKERS] Safe/Fast I/O ...  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-hackers
The Hermit Hacker wrote:

>         ...but, with MMAP, unless I'm mistaken, you'd essentially be
> reading the file(s) into memory and then manipulating the file(s) there.
> Which means one helluva large amount of RAM being required...no?

Not exactly. Memory mapping is used only to map file into some memory
addresses but not put into memory. Disk sectors are copied into memory
on demand. If some mmaped page is accessed - it is copied from disk into
memory.

The main reason of using memory mapping is that you don't have to create
unnecessary buffers. Normally, for every operation you have to create
some in-memory buffer, copy the data there, do some operations, put the
data back into file. In case of memory mapping you may avoid of creating
of unnecessary buffers, and moreover you may call your system functions
less frequently. There are also additional savings. (Less memory
copying, reusing memory if several processes map the same file)

I don't think there exist more efficient solutions.

Mike

--
WWW: http://www.lodz.pdi.net/~mimo  tel: Int. Acc. Code + 48 42 148340
add: Michal Mosiewicz  *  Bugaj 66 m.54 *  95-200 Pabianice  *  POLAND

pgsql-hackers by date:

Previous
From: ocie@paracel.com
Date:
Subject: Re: [HACKERS] Safe/Fast I/O ...
Next
From: "Thomas G. Lockhart"
Date:
Subject: Broken makefile for docs