From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@lists.postgresql.org, Andres Freund <andres@anarazel.de>
Subject: Re: Splitting up guc.c
Date: Sun, 11 Sep 2022 13:52:55 -0400
Message-ID: <925946.1662918775@sss.pgh.pa.us> (raw)
In-Reply-To: <666417.1662862120@sss.pgh.pa.us>
References: <587607.1662836699@sss.pgh.pa.us>
<Yx0vHEBXwcUggZYK@paquier.xyz>
<666417.1662862120@sss.pgh.pa.us>
I wrote:
> Michael Paquier <michael@paquier.xyz> writes:
>> One part that I have found a bit strange lately about guc.c is that we
>> have mix the core machinery with the SQL-callable parts. What do you
>> think about the addition of a gucfuncs.c in src/backend/utils/adt/ to
>> split things a bit more?
> I might be wrong, but I think the SQL-callable stuff makes use
> of some APIs that are currently private in guc.c. So we'd have
> to expose more API to make that possible. Maybe that wouldn't
> be a bad thing, but it seems to be getting beyond the original
> idea here.
I tried this just to see, and it worked out better than I thought.
The key extra idea is to also pull out the functions implementing
the SET and SHOW commands, because (unsurprisingly) those are just
about in the same place dependency-wise as the SQL functions, and
they have some common subroutines.
I had to export get_config_unit_name(), config_enum_get_options(),
and _ShowOption() (here renamed to ShowGUCOption()) to make this
work. That doesn't seem too awful.
v2 attached does this, without any further relocation of hook
functions as yet. I now see these file sizes:
$ wc guc*c
2629 9372 69467 guc-file.c
6425 22282 176816 guc.c
1048 3005 26962 guc_funcs.c
939 2693 22915 guc_hooks.c
4877 13163 126769 guc_tables.c
15918 50515 422929 total
$ size guc*o
text data bss dec hex filename
13653 4 112 13769 35c9 guc-file.o
46589 0 564 47153 b831 guc.o
8509 0 0 8509 213d guc_funcs.o
6951 0 112 7063 1b97 guc_hooks.o
43570 62998 216 106784 1a120 guc_tables.o
So this removes just about a thousand more lines from guc.c,
which seems worth doing.
regards, tom lane
Attachments:
split-up-guc-code-2.patch.gz (application/x-gzip, 85.3K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, andres@anarazel.de
Subject: Re: Splitting up guc.c
In-Reply-To: <925946.1662918775@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox