pgsql: Dramatically reduce System V shared memory consumption.

Lists: pgsql-committers
From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Dramatically reduce System V shared memory consumption.
Date: 2012-06-28 15:25:59
Message-ID: E1SkGbX-00075z-AP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Dramatically reduce System V shared memory consumption.

Except when compiling with EXEC_BACKEND, we'll now allocate only a tiny
amount of System V shared memory (as an interlock to protect the data
directory) and allocate the rest as anonymous shared memory via mmap.
This will hopefully spare most users the hassle of adjusting operating
system parameters before being able to start PostgreSQL with a
reasonable value for shared_buffers.

There are a bunch of documentation updates needed here, and we might
need to adjust some of the HINT messages related to shared memory as
well. But it's not 100% clear how portable this is, so before we
write the documentation, let's give it a spin on the buildfarm and
see what turns red.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b0fc0df9364d2d2d17c0162cf3b8b59f6cb09f67

Modified Files
--------------
src/backend/port/sysv_shmem.c | 89 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 86 insertions(+), 3 deletions(-)


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Cc: Robert Haas <rhaas(at)postgresql(dot)org>
Subject: Re: pgsql: Dramatically reduce System V shared memory consumption.
Date: 2012-06-29 17:34:05
Message-ID: 201206291934.05319.andres@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Hi Robert,

You have a small typo in the patch:

+ /*
+ * pagesize will, for practical purposes, always be a power of two.
+ * But just in case it isn't, we do it this way instead of using
+ * TYPEALIGN().
+ */
+ AnonymousShmemSize = size;
+ if (size % pagesize != 0)
+ AnonymousShmemSize += pagesize - (size % pagesize);
+
+ /*
+ * We assume that no one will attempt to run PostgreSQL 9.3 or later
+ * on systems that are ancient enough that anonymous shared memory is
+ * not supported, such as pre-2.4 versions of Linux. If that turns
out
+ * to be false, we might need to add a run-time test here and do this
+ * only if the running kernel supports it.
+ */
+ AnonymousShmem = mmap(NULL, size, PROT_READ|PROT_WRITE, PG_MMAP_FLAGS,
+ -1, 0);

Note that you use size in the mmap...

Andres
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org, Robert Haas <rhaas(at)postgresql(dot)org>
Subject: Re: pgsql: Dramatically reduce System V shared memory consumption.
Date: 2012-06-29 19:12:57
Message-ID: 12671.1340997177@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> Hi Robert,
> You have a small typo in the patch:

Fixed, thanks for the report.

regards, tom lane