Hi,
Thank you for the previous discussion while ago.
I’m afraid I haven't replied to all.
To move forward this development I attached a PoC patch.
I introduced a guc called shared_catacache_mem to specify
how much memory is supposed be allocated on the shared memory area.
It defaults to zero, which indicates that no catalog cache is shared
but allocated on each backend MemoryContext (same as current Postgres).
At this moment this patch only allocates catalog cache header and CatCache data on the shared memory area.
It doesn't do much work, just starting and stopping postgres server with shared_catcache_mem non-zero.
Shared version CatCacheHdr is put on the postgres-initialized shared memory so that backends attach it
and build SysCache[] to store pointers of CatCache.
Each CatCache, CatCTup and CacCList is also allocated on the shared memory area,
where the limit size is the value of shared_catcache_mem and backed by DSA.
This area is first created at the postgres-initialized shared memory and re-initialized as DSA area
because the address of postgres-initialized shared area does not change among different process
and hopefully makes it easy to handle pointers on the shared memory.
(Though I'm still struggling to grasp the idea of DSA and underlying DSM..)
The followings are major items I haven't touched:
- make hash table of each CatCache shared, which I'm going to take advantage of dshash
- how to evict shared cache (LRU mechanism)
- how to treat cache visibility and invalidation coming from transactions including DDL
- how to alleviate the slowness compared to current PostgreSQL
- make relcache shared as well as catcache
If you have any insights/reactions/suggestions, please feel free to comment.
====================
Takeshi Ideriha
Fujitsu Limited