From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Markus Wanner <markus(at)bluegap(dot)ch> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, 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:10:53 |
Message-ID: | 201008091610.o79GAru12011@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Markus Wanner wrote:
> Hi,
>
> On 08/09/2010 05:02 PM, Bruce Momjian wrote:
> > [ Sorry to be jumping into this thread late.]
>
> No problem at all.
>
> > I am not sure threads would greatly help us.
>
> Note that I'm absolutely, certainly not advocating the use of threads
> for Postgres.
>
> > 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.
>
> I don't quite follow what you are trying to say here. Whether or not
> structures are contiguous in memory might affect performance, but I
> don't see the relation to programmer's habits and/or knowledge.
>
> With our process-based design, the default is private memory (i.e. not
> shared). If you need shared memory, you must specify a certain amount in
> advance. That chunk of shared memory then is reserved and can't ever be
> used by another subsystem. Even if you barely ever need that much shared
> memory for the subsystem in question.
Once multiple threads are using the same local memory, you have the same
issues of being unable to resize it because repalloc can change the
pointer location.
> That's opposed to what lots of people are used to with the threaded
> approach, where shared memory is the default. And where you can easily
> and dynamically allocate *shared* memory. Whatever chunk of shared
> memory one subsystem doesn't need is available to another one (modulo
> fragmentation of the dynamic allocator, perhaps, but..)
Well, this could be done with shared memory as well.
My point is that you can treat malloc the same as "add shared memory",
to some extent, with the same limiations.
--
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:20:18 | Re: ERROR: argument to pg_get_expr() must come from system catalogs |
Previous Message | Bruce Momjian | 2010-08-09 16:03:42 | Re: dynamically allocating chunks from shared memory |