pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Split up guc.c for better build speed and ease of maintenance.
Date: Tue, 13 Sep 2022 15:13:17 +0000
Message-ID: <E1oY7bA-000AsC-Lv@gemulon.postgresql.org> (raw)

Split up guc.c for better build speed and ease of maintenance.

guc.c has grown to be one of our largest .c files, making it
a bottleneck for compilation.  It's also acquired a bunch of
knowledge that'd be better kept elsewhere, because of our not
very good habit of putting variable-specific check hooks here.
Hence, split it up along these lines:

* guc.c itself retains just the core GUC housekeeping mechanisms.
* New file guc_funcs.c contains the SET/SHOW interfaces and some
  SQL-accessible functions for GUC manipulation.
* New file guc_tables.c contains the data arrays that define the
  built-in GUC variables, along with some already-exported constant
  tables.
* GUC check/assign/show hook functions are moved to the variable's
  home module, whenever that's clearly identifiable.  A few hard-
  to-classify hooks ended up in commands/variable.c, which was
  already a home for miscellaneous GUC hook functions.

To avoid cluttering a lot more header files with #include "guc.h",
I also invented a new header file utils/guc_hooks.h and put all
the GUC hook functions' declarations there, regardless of their
originating module.  That allowed removal of #include "guc.h"
from some existing headers.  The fallout from that (hopefully
all caught here) demonstrates clearly why such inclusions are
best minimized: there are a lot of files that, for example,
were getting array.h at two or more levels of remove, despite
not having any connection at all to GUCs in themselves.

There is some very minor code beautification here, such as
renaming a couple of inconsistently-named hook functions
and improving some comments.  But mostly this just moves
code from point A to point B and deals with the ensuing
needs for #include adjustments and exporting a few functions
that previously weren't exported.

Patch by me, per a suggestion from Andres Freund; thanks also
to Michael Paquier for the idea to invent guc_funcs.c.

Discussion: https://postgr.es/m/587607.1662836699@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0a20ff54f5e66158930d5328f89f087d4e9ab400

Modified Files
--------------
contrib/amcheck/verify_nbtree.c             |     1 +
contrib/ltree/_ltree_gist.c                 |     1 +
contrib/ltree/_ltree_op.c                   |     1 +
contrib/ltree/lquery_op.c                   |     1 +
contrib/ltree/ltree_gist.c                  |     1 +
contrib/pg_surgery/heap_surgery.c           |     1 +
contrib/pg_trgm/trgm_op.c                   |     1 +
src/backend/access/brin/brin.c              |     1 +
src/backend/access/table/tableamapi.c       |     1 +
src/backend/access/transam/xlog.c           |   176 +-
src/backend/access/transam/xlogprefetcher.c |     2 +-
src/backend/access/transam/xlogrecovery.c   |   317 +-
src/backend/backup/basebackup.c             |     1 +
src/backend/catalog/aclchk.c                |     1 +
src/backend/catalog/namespace.c             |     2 +-
src/backend/catalog/pg_parameter_acl.c      |     1 +
src/backend/commands/cluster.c              |     1 +
src/backend/commands/indexcmds.c            |     1 +
src/backend/commands/tablespace.c           |     2 +-
src/backend/commands/trigger.c              |    16 +
src/backend/commands/variable.c             |   271 +-
src/backend/libpq/pqcomm.c                  |   104 +-
src/backend/partitioning/partbounds.c       |     1 +
src/backend/port/sysv_shmem.c               |    19 +-
src/backend/port/win32_shmem.c              |    16 +
src/backend/postmaster/autovacuum.c         |    27 +
src/backend/replication/repl_gram.y         |     1 +
src/backend/replication/repl_scanner.l      |     1 +
src/backend/replication/syncrep.c           |     1 +
src/backend/replication/syncrep_gram.y      |     1 +
src/backend/replication/syncrep_scanner.l   |     1 +
src/backend/storage/buffer/localbuf.c       |    20 +-
src/backend/storage/ipc/ipci.c              |     1 +
src/backend/storage/lmgr/predicate.c        |     4 +-
src/backend/tcop/postgres.c                 |    53 +
src/backend/tsearch/dict.c                  |     1 +
src/backend/utils/adt/pg_locale.c           |     1 +
src/backend/utils/adt/selfuncs.c            |     1 +
src/backend/utils/adt/varchar.c             |     1 +
src/backend/utils/adt/varlena.c             |     1 +
src/backend/utils/cache/ts_cache.c          |     5 +-
src/backend/utils/error/elog.c              |   187 +-
src/backend/utils/init/postinit.c           |    50 +-
src/backend/utils/misc/Makefile             |     2 +
src/backend/utils/misc/guc.c                | 17318 ++++++++------------------
src/backend/utils/misc/guc_funcs.c          |  1047 ++
src/backend/utils/misc/guc_tables.c         |  4875 ++++++++
src/include/access/tableam.h                |     4 +-
src/include/access/xlog.h                   |     4 +-
src/include/commands/variable.h             |    38 -
src/include/replication/syncrep.h           |     6 -
src/include/tcop/tcopprot.h                 |     3 -
src/include/tsearch/ts_cache.h              |     4 +-
src/include/utils/elog.h                    |     4 -
src/include/utils/guc.h                     |    50 +-
src/include/utils/guc_hooks.h               |   158 +
src/include/utils/guc_tables.h              |    22 +-
src/include/utils/pg_locale.h               |    11 -
src/test/regress/regress.c                  |     1 +
59 files changed, 12591 insertions(+), 12253 deletions(-)



Message-ID: <E1oY7bA-000AsC-Lv@gemulon.postgresql.org>
Permalink:  ../E1oY7bA-000AsC-Lv@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oY7bA-000AsC-Lv@gemulon.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Split up guc.c for better build speed and ease of maintenance.
  In-Reply-To: <E1oY7bA-000AsC-Lv@gemulon.postgresql.org>
  References: <E1oY7bA-000AsC-Lv@gemulon.postgresql.org>

* 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