Re: [HACKERS] Safe/Fast I/O ...

From: Garrett Wollman <wollman(at)khavrinen(dot)lcs(dot)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Safe/Fast I/O ...
Date: 1998-04-13 16:26:59
Message-ID: 199804131626.MAA25613@khavrinen.lcs.mit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[Please forgive me for the way this post is put together; I'm not
actually on your mailing-list, but was just perusing the archives.]

Michal Mosiewicz <mimo(at)interdata(dot)com(dot)pl> writes:

> 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)

Additionally, if your operating system is at all reasonable, using
memory mapping allows you to take advantage of all the work that has
gone into tuning your VM system. If you map a large file, and then
access in some way that shows reasonable locality, the VM system will
probably be able to do a better job of page replacement on a
system-wide basis than you could do with a cache built into your
application. (A good system will also provide other benefits, such as
pre-faulting and extended read ahead.)

Of course, it does have one significant drawback: memory-mapped regions
do not automatically extend when their underlying files do. So, for
interacting with a structure that shows effectively linear access and
growth, asynchronous I/O is more likely to be a benefit, since AIO can
extend a file asynchronously, whereas other mechanisms will block
while the file is being extended. (Depending on the system, this may
not be true for multi-threaded programs.)

-GAWollman

--
Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same
wollman(at)lcs(dot)mit(dot)edu | O Siem / The fires of freedom
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-04-13 16:31:10 Re: [HACKERS] still getting FATAL errors on btree's...
Previous Message David Hartwig 1998-04-13 16:10:58 Re: [HACKERS] Re: [INTERFACES] New pg_type for large object