diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-10-14 12:36:14 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-10-14 12:36:14 -0400 |
commit | f13b2088fa2d4455936e65459b77698a4452f932 (patch) | |
tree | a6fe1d9180324481b4ae4368c7d3af883e930094 /src/include/utils/guc_tables.h | |
parent | 3057465acfbea2f3dd7a914a1478064022c6eecd (diff) | |
download | postgresql-f13b2088fa2d4455936e65459b77698a4452f932.tar.gz postgresql-f13b2088fa2d4455936e65459b77698a4452f932.zip |
Add auxiliary lists to GUC data structures for better performance.
The previous patch made addition of new GUCs cheap, but other GUC
operations aren't improved and indeed get a bit slower, because
hash_seq_search() is slower than just scanning a pointer array.
However, most performance-critical GUC operations only need
to touch a relatively small fraction of the GUCs; especially
so for AtEOXact_GUC(). We can improve matters at the cost
of a bit more space by adding dlist or slist links to the
GUC data structures. This patch invents lists that track
(1) all GUCs with non-default "source";
(2) all GUCs with nonempty state stack (implying they've
been changed in the current transaction);
(3) all GUCs due for reporting to the client.
All of guc.c's performance-critical cases can make use of one or
another of these lists to avoid searching the whole hash table.
In particular, the stack list means that transaction end
doesn't take time proportional to the number of GUCs, but
only to the number changed in the current transaction.
Discussion: https://postgr.es/m/2982579.1662416866@sss.pgh.pa.us
Diffstat (limited to 'src/include/utils/guc_tables.h')
-rw-r--r-- | src/include/utils/guc_tables.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index 99740e7e48c..51f7f09fde0 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -14,6 +14,7 @@ #ifndef GUC_TABLES_H #define GUC_TABLES_H 1 +#include "lib/ilist.h" #include "utils/guc.h" /* @@ -138,6 +139,11 @@ typedef struct guc_stack * if the value came from an internal source or the config file. Similarly * for reset_srole (which is usually BOOTSTRAP_SUPERUSERID, but not always). * + * Variables that are currently of active interest for maintenance + * operations are linked into various lists using the xxx_link fields. + * The link fields are unused/garbage in variables not currently having + * the specified properties. + * * Note that sourcefile/sourceline are kept here, and not pushed into stacked * values, although in principle they belong with some stacked value if the * active value is session- or transaction-local. This is to avoid bloating @@ -163,6 +169,12 @@ struct config_generic Oid reset_srole; /* role that set the reset value */ GucStack *stack; /* stacked prior values */ void *extra; /* "extra" pointer for current actual value */ + dlist_node nondef_link; /* list link for variables that have source + * different from PGC_S_DEFAULT */ + slist_node stack_link; /* list link for variables that have non-NULL + * stack */ + slist_node report_link; /* list link for variables that have the + * GUC_NEEDS_REPORT bit set in status */ char *last_reported; /* if variable is GUC_REPORT, value last sent * to client (NULL if not yet sent) */ char *sourcefile; /* file current setting is from (NULL if not |