From: | <david(at)andl(dot)org> |
---|---|
To: | |
Cc: | "'Pg Hackers'" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Shared memory and processes |
Date: | 2016-04-28 03:20:33 |
Message-ID: | 007301d1a0fc$ef26df80$cd749e80$@andl.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> From: Thomas Munro [mailto:thomas(dot)munro(at)enterprisedb(dot)com]
> > Does Postgres provide a convenient way for one process to pass data to
> > another using shared memory?
>
> 1. Look at ShmemInitStruct, ShmemInitHash (as in hash table), ShmemInitQueue
> in storage/shmem.h. These use memory that is mapped at the same address in
> every backend (process) which is convenient for sharing data structures with
> internal pointers. The amount of memory available is fixed at cluster
> startup however.
Thanks. That limit could be an issue. The notes in shmem.c are helpful.
> 2. Look at dsm_XXX in storage/dsm.h. This subsystem provides segments of
> memory that is "dynamic" in the sense that it is limited only by your
> system's available virtual memory, but you have to explicitly attach these
> segment in any backend that wants to access them by passing a handle around
> and the memory may be mapped at any address in each backend, so you need to
> work harder to build data structures that reference each other (using offsets
> rather than pointers, that kind of thing). DSM segments won't work well if
> you try to create large numbers of them, so you'll need to provide a way to
> manage the space inside a smallish number of large chunks of DSM memory
> yourself (this is a problem I'm working to fix by providing a general purpose
> allocator backed by a bunch of DSM segments -- watch this space). LWLocks
> (our usual lock primitive for cases where spinlocks are inappropriate)
> currently don't work correctly inside DSM segments (this too will be fixed).
I've now found this through the test_shm_mq sample. Looks like an answer, if quite a bit of machinery needed.
Thanks for the pointers.
Regards
David M Bennett FACS
Andl - A New Database Language - andl.org
From | Date | Subject | |
---|---|---|---|
Next Message | david | 2016-04-28 03:24:12 | Re: Shared memory and processes |
Previous Message | Tom Lane | 2016-04-28 03:04:42 | Re: Fix for OpenSSL error queue bug |