Re: Modernizing our GUC infrastructure

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2022-10-07T19:31:26Z
Lists: pgsql-hackers

Attachments

I wrote:
>> Attached is a patch series that attempts to modernize our GUC
>> infrastructure, in particular removing the performance bottlenecks
>> it has when there are lots of GUC variables.

> Rebased over 0a20ff54f.

Here's a v3 rebased up to HEAD.  The only real change is that I added
a couple of "Assert(GetMemoryChunkContext(ptr) == GUCMemoryContext)"
checks in hopes of improving detection of not-updated code that is
still using malloc/free where it should be using guc_malloc/guc_free.
This is per the nearby discussion of whether the mcxt.c infrastructure
could recognize that [1].  I experimented a bit with leaving out parts
of the 0002 patch to simulate such mistakes, and at least on a Linux
box that seems to produce fairly intelligible errors now.  In the case
of free'ing a palloc'd pointer, what you get is a message from glibc
followed by abort(), so their error detection is pretty solid too.

I'm feeling pretty good about this patchset now.  Does anyone want
to review it further?

			regards, tom lane

[1] https://postgr.es/m/2910981.1665080361%40sss.pgh.pa.us

Commits

  1. Add auxiliary lists to GUC data structures for better performance.

  2. Replace the sorted array of GUC variables with a hash table.

  3. Store GUC data in a memory context, instead of using malloc().

  4. Make some minor improvements in memory-context infrastructure.