Re: Shared memory usage in PostgreSQL 9.1

From: Christoph Zwerschke <cito(at)online(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Shared memory usage in PostgreSQL 9.1
Date: 2011-12-03 17:02:42
Message-ID: 4EDA5632.8090801@online.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am 03.12.2011 15:34, schrieb Tomas Vondra:
> Do you need to know an exact value or are you just interested why the
> values in docs are not exact?

Both. I'm writing an installation script that calculates the necessary
IPC memory and increases the limit on the OS level (kernel.shmmax) if
needed. I want to increase the limit only as much as really necessary,
so I need to calculate the IPC usage as exactly as possible.

(Btw, what negative consequences - if any - does it have if I set
kernel.shmmax higher as necessary, like all available memory? Does this
limit serve only as a protection against greedy applications?)

> If you want to see what exactly needs how much memory, check the
> src/backend/storage/ipc/ipci.c file in sources. I've added some log
> messages, and this is the result on my 64bit machine (using the values
> you've posted):

Thanks a lot, that was helpful. So it seems the values in the docs are
only correct for a 32 bit server.

But I still don't understand this:

In our example, we have set shared_buffers to:

400 MB = 419430400 Bytes

but according to your log the used memory is:

buffers = 424669472 Bytes

This is a discrepancy of 1.25%.

The difference could be explained by taking credit for the descriptors
which may not be comprised in the shared_buffers setting, even if the
shared_buffers value is set in memory units. But according to the docs,
the descriptors should use 208/8192 = 2.5%. And on a 64bit machine, the
descriptors should use even more memory, i.e. up to 5%.

So I'm still a bit confused.

-- Christoph

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-12-03 17:39:35 Re: Shared memory usage in PostgreSQL 9.1
Previous Message Oleg Serov 2011-12-03 15:31:05 Re: Postgresql + corrupted disk = data loss. (Need help for database recover)