On the Serializable Snapshot Isolation thread, Heikki pointed out a collection of objects in an HTAB which didn't really need its key on VirtualTransactionId, but there isn't really any other useful key, either. One of these objects may live and die, seeing use from multiple processes, without ever getting a TransactionId assigned; and it needs to be in a collection in shared memory the whole time. This suggests to me that some sort of list would be better. SHM_QUEUE objects provide the infrastructure for maintaining a shared memory linked list, but they don't do anything about the allocation and release of the space for the objects. So it occurs to me that I'm using an HTAB for this collection because it provides the infrastructure for managing the memory for the collection, rather than because I need hash lookup. :-( It works, but that hardly seems optimal. Have I missed something we already have which could meet that need? If not, how would people feel about a ShmList implementation? A quick first draft for the API (which can almost certainly be improved, so don't be shy), is: ShmList ShmInitList(const char *name, Size entrySize, int initalEntryAlloc, int maxExtensions); Size ShmListEstimateSize(ShmList list); void *CreateShmListEntry(ShmList list); void ReleaseShmListEntry(ShmList list, void *entry); int ShmListSize(ShmList list); void *ShmListFirst(ShmList list); void *ShmListNext(ShmList list, void *entry); I see this as grabbing the initial allocation, filling it with zeros, and then creating a linked list of available entries. Internally the entries would be a SHM_QUEUE structure followed by space for the entrySize passed on init. A "create entry" call would remove an entry from the available list, link it into the collection, and return a pointer to the structure. Releasing an entry would remove it from the collection list, zero it, and link it to the available list. Hopefully the rest is fairly self-evident -- if not, let me know. Thoughts? -Kevin
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers