Shared Memory hash tables only at startup
Hi
It is clear that all of the shared memory hash tables are created during
startup using
*ShmemInitHash() *
*(In practice, all creations are done in the postmasterprocess; child
processes should always be attaching to existing tables.)*
Is there any specific reason to do so or my understanding was wrong(we can
create shared memory hash table at run time too?)
TIA
harry
hariprasath nallasamy <hariprasathnallasamy@gmail.com> writes:
*(In practice, all creations are done in the postmasterprocess; child
processes should always be attaching to existing tables.)*
Yeah ...
Is there any specific reason to do so or my understanding was wrong(we can
create shared memory hash table at run time too?)
Well, if you don't mind resolving the race conditions that you're going to
have, you could possibly do that. In practice though, unless it's a very
small hash table, it's going to need to be accounted for in the sizing
calculations in CreateSharedMemoryAndSemaphores, which means you might
as well create it during that function too.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, May 2, 2017 at 11:54 PM, hariprasath nallasamy
<hariprasathnallasamy@gmail.com> wrote:
Hi
It is clear that all of the shared memory hash tables are created during
startup using ShmemInitHash()(In practice, all creations are done in the postmaster
process; child processes should always be attaching to existing tables.)Is there any specific reason to do so or my understanding was wrong(we can
create shared memory hash table at run time too?)
Because we use processes and not threads, the space has to be
allocated up front and then inherited by other process in order to
inherit the same memory map so that raw pointers can be exchanged
between backends. DynaHash is a data structure made out of raw
pointers.
I have a proposal[1]/messages/by-id/CAEepm=3d8o8XdVwYT6O=bHKsKAM2pu2D6sV1S_=4d+jStVCE7w@mail.gmail.com that would provide dynamic concurrent hash tables
that can be created after startup using DSM/DSA memory, but then you
have to deal with kooky pointers, which falls out of Postgres's
policies of avoiding multithreading and embracing parallelism.
[1]: /messages/by-id/CAEepm=3d8o8XdVwYT6O=bHKsKAM2pu2D6sV1S_=4d+jStVCE7w@mail.gmail.com
--
Thomas Munro
http://www.enterprisedb.com
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers