Re: WAL & SHM principles

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Martin Devera <devik(at)cdi(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: WAL & SHM principles
Date: 2001-03-07 14:59:55
Message-ID: 200103071459.JAA03250@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 2) SHM vs. MMAP
> Why don't use mmap to share pages (instead of shm) ? There would be no
> problem with tuning pg's buffer cache size - it is balanced by OS.
> When using SHM there are often two copies of page: one in OS' page cache
> and one in SHM (vaste of memory).
> When using mmap the data goes (almost) directly from HDD into your memory
> page - now you need to copy it from OS' page to PG's page.
> There is one problem: how to assure that dirtied page is not flushed
> before its xlog. One can use mlock but you often need root privileges to
> use it. Another way is to implement own COW (copy on write) to create
> intermediate buffers used only until xlog is flushed.

This was brought up a week ago, and I consider it an interesting idea.
The only problem is that we would no longer have control over which
pages made it to disk. The OS would perhaps write pages as we modified
them. Not sure how important that is.

The good news is that most/all OS's are smart enought that if two
processes mmap() the same file, they see each other's changes, so in a
sense it is shared memory, but a much larger, smarter pool of shared
memory than what we have now. We would still need buffer headers and
stuff because we need to synchronize access to the buffers.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christof Petig 2001-03-07 15:08:47 Re: Query Planning time increased 3 times on 7.1 compared to 7.0.3
Previous Message Bruce Momjian 2001-03-07 14:50:21 Re: AW: Proposed WAL changes