From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | 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 16:03:42 |
Message-ID: | 201008091603.o79G3gp05774@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Robert Haas wrote:
> On Mon, Aug 9, 2010 at 11:02 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > I am not sure threads would greatly help us. ?The major problem is that
> > all of our our structures are currently contiguous in memory for quick
> > access. ?I don't see how threading would help with that. ?We could use
> > realloc(), but we can do the same in shared memory if we had a chunk
> > infrastructure, though concurrent access to that memory would hurt us in
> > either threads or shared memory.
> >
> > Fundamentally, recreating the libc memory allocation routines is not
> > that hard. ?(Everyone has to detach from the shared memory segment, but
> > they have to stop using it too, so it doesn't seem that hard.)
>
> I actually don't think that's true. The advantage (and disadvantage)
> of using threads is that everything runs in one address space. So you
> just allocate more memory and everyone immediately sees it. In a
> process environment, that's not the case: to expand or shrink the size
> of the shared memory arena, everyone needs to explicitly change their
> own mapping.
You can't expand the size of malloc'ed memory --- you have to call
realloc(), and then you effectively get a new pointer. Shared memory
has a similar limitation. If you allocate shared memory in chunks so
you don't need to change the location, you are effectively doing another
malloc(), like you would in a threaded process.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2010-08-09 16:10:53 | Re: dynamically allocating chunks from shared memory |
Previous Message | Tom Lane | 2010-08-09 15:41:24 | Re: dynamically allocating chunks from shared memory |