Re: dynamically allocating chunks from shared memory

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Markus Wanner <markus(at)bluegap(dot)ch>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dynamically allocating chunks from shared memory
Date: 2010-08-09 20:09:14
Message-ID: AANLkTi=ZUDA73qYpnp80pKS2N8kR5EiOQN0m83Drmn-4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 9, 2010 at 3:20 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Mon, Aug 9, 2010 at 11:41 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> ... and on some platforms, it'll be flat out impossible.  We looked at
>>> this years ago and concluded that changing the size of the shmem segment
>>> after postmaster start was impractical from a portability standpoint.
>>> I have not seen anything to change that conclusion.
>
>> I haven't done extensive research into this, but I did take a look at
>> it briefly.  It looked to me like the style of shared memory we're
>> using now (I guess it's System V) has no way to resize a shared memory
>> segment at all, and certainly no way that's portable.  However it also
>> looked as though POSIX shm (shm_open, etc.) can be resized using
>> ftruncate().  Whether this is portable to all the platforms we run on,
>> or whether the behavior of ftruncate() in combination with shm_open()
>> is in the standard, I'm not sure.
>
> It's not portable.  That's exactly what we were looking into back when.

Uggh, that sucks. Can you provide any more details?

>> I believe I went back and reread
>> the old threads on this topic and it seems like the sticking point as
>> far as POSIX shm goes it that it lacks a readable equivalent of
>> shm_nattch.
>
> Yeah, that was another little problem.  In principle though we only need
> one SysV-style shmem segment to get the required interlock, and there
> could be add-on shmem segments using POSIX or other APIs.  But that
> doesn't get you out from under the portability issue or the memory space
> management issue (it's unlikely you can enlarge a segment without
> remapping it).

Unlikely is probably an understatement. Still, enlarging a segment
with remapping might be workable for some useful subset of the cases.
But, if enlarging it can't be done portably, then we're pretty much
dead in the water.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-08-09 20:10:47 Re: patch: to_string, to_array functions
Previous Message Tom Lane 2010-08-09 20:08:13 Re: patch: to_string, to_array functions