pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Add macros to make AllocSetContextCreate() calls simpler and saf 2+ messages / 1 participants [nested] [flat]
* pgsql: Add macros to make AllocSetContextCreate() calls simpler and saf @ 2016-08-27 21:50 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2016-08-27 21:50 UTC (permalink / raw) To: pgsql-committers Add macros to make AllocSetContextCreate() calls simpler and safer. I found that half a dozen (nearly 5%) of our AllocSetContextCreate calls had typos in the context-sizing parameters. While none of these led to especially significant problems, they did create minor inefficiencies, and it's now clear that expecting people to copy-and-paste those calls accurately is not a great idea. Let's reduce the risk of future errors by introducing single macros that encapsulate the common use-cases. Three such macros are enough to cover all but two special-purpose contexts; those two calls can be left as-is, I think. While this patch doesn't in itself improve matters for third-party extensions, it doesn't break anything for them either, and they can gradually adopt the simplified notation over time. In passing, change TopMemoryContext to use the default allocation parameters. Formerly it could only be extended 8K at a time. That was probably reasonable when this code was written; but nowadays we create many more contexts than we did then, so that it's not unusual to have a couple hundred K in TopMemoryContext, even without considering various dubious code that sticks other things there. There seems no good reason not to let it use growing blocks like most other contexts. Back-patch to 9.6, mostly because that's still close enough to HEAD that it's easy to do so, and keeping the branches in sync can be expected to avoid some future back-patching pain. The bugs fixed by these changes don't seem to be significant enough to justify fixing them further back. Discussion: <21072.1472321324@sss.pgh.pa.us> Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/ea268cdc9a2631da4a5748b00059a9fd43470d0e Modified Files -------------- contrib/bloom/blinsert.c | 8 ++---- contrib/dblink/dblink.c | 4 +-- contrib/file_fdw/file_fdw.c | 4 +-- contrib/pg_trgm/trgm_regexp.c | 4 +-- contrib/postgres_fdw/postgres_fdw.c | 20 ++++---------- contrib/sepgsql/uavc.c | 6 ++--- contrib/test_decoding/test_decoding.c | 4 +-- src/backend/access/brin/brin.c | 16 +++-------- src/backend/access/brin/brin_tuple.c | 4 +-- src/backend/access/common/printtup.c | 4 +-- src/backend/access/gin/ginbtree.c | 4 +-- src/backend/access/gin/ginfast.c | 4 +-- src/backend/access/gin/gininsert.c | 12 +++------ src/backend/access/gin/ginscan.c | 8 ++---- src/backend/access/gin/ginvacuum.c | 4 +-- src/backend/access/gin/ginxlog.c | 5 ++-- src/backend/access/gist/gist.c | 8 ++---- src/backend/access/gist/gistscan.c | 8 ++---- src/backend/access/heap/rewriteheap.c | 4 +-- src/backend/access/nbtree/nbtree.c | 4 +-- src/backend/access/nbtree/nbtutils.c | 6 ++--- src/backend/access/spgist/spginsert.c | 8 ++---- src/backend/access/spgist/spgscan.c | 4 +-- src/backend/access/spgist/spgxlog.c | 4 +-- src/backend/access/transam/multixact.c | 6 ++--- src/backend/access/transam/parallel.c | 12 +++------ src/backend/access/transam/xact.c | 8 ++---- src/backend/access/transam/xlog.c | 4 +-- src/backend/access/transam/xloginsert.c | 4 +-- src/backend/bootstrap/bootstrap.c | 4 +-- src/backend/catalog/objectaddress.c | 4 +-- src/backend/commands/analyze.c | 12 +++------ src/backend/commands/cluster.c | 4 +-- src/backend/commands/copy.c | 8 ++---- src/backend/commands/event_trigger.c | 8 ++---- src/backend/commands/indexcmds.c | 4 +-- src/backend/commands/policy.c | 4 +-- src/backend/commands/trigger.c | 8 ++---- src/backend/commands/vacuum.c | 4 +-- src/backend/executor/execUtils.c | 12 +++------ src/backend/executor/functions.c | 4 +-- src/backend/executor/nodeFunctionscan.c | 4 +-- src/backend/executor/nodeHash.c | 8 ++---- src/backend/executor/nodeRecursiveunion.c | 8 ++---- src/backend/executor/nodeSetOp.c | 8 ++---- src/backend/executor/nodeSubplan.c | 8 ++---- src/backend/executor/nodeUnique.c | 4 +-- src/backend/executor/nodeWindowAgg.c | 18 +++++-------- src/backend/executor/spi.c | 23 +++++----------- src/backend/executor/tqueue.c | 4 +-- src/backend/libpq/be-fsstubs.c | 4 +-- src/backend/libpq/hba.c | 14 +++------- src/backend/optimizer/geqo/geqo_eval.c | 4 +-- src/backend/optimizer/util/clauses.c | 8 ++---- src/backend/postmaster/autovacuum.c | 24 +++++------------ src/backend/postmaster/bgwriter.c | 4 +-- src/backend/postmaster/checkpointer.c | 4 +-- src/backend/postmaster/pgstat.c | 4 +-- src/backend/postmaster/postmaster.c | 4 +-- src/backend/postmaster/walwriter.c | 4 +-- src/backend/replication/logical/logical.c | 6 ++--- src/backend/replication/logical/reorderbuffer.c | 6 ++--- src/backend/replication/logical/snapbuild.c | 4 +-- src/backend/replication/walsender.c | 4 +-- src/backend/storage/buffer/localbuf.c | 4 +-- src/backend/storage/file/reinit.c | 4 +-- src/backend/storage/lmgr/lwlock.c | 4 +-- src/backend/storage/smgr/md.c | 10 +++---- src/backend/tcop/postgres.c | 8 ++---- src/backend/tsearch/spell.c | 4 +-- src/backend/utils/adt/array_expanded.c | 4 +-- src/backend/utils/adt/arrayfuncs.c | 8 ++---- src/backend/utils/adt/jsonfuncs.c | 16 +++-------- src/backend/utils/adt/xml.c | 6 ++--- src/backend/utils/cache/catcache.c | 4 +-- src/backend/utils/cache/evtcache.c | 4 +-- src/backend/utils/cache/plancache.c | 35 ++++++++----------------- src/backend/utils/cache/relcache.c | 18 +++---------- src/backend/utils/cache/ts_cache.c | 4 +-- src/backend/utils/cache/typcache.c | 8 ++---- src/backend/utils/fmgr/funcapi.c | 4 +-- src/backend/utils/hash/dynahash.c | 4 +-- src/backend/utils/init/postinit.c | 4 +-- src/backend/utils/misc/guc-file.l | 4 +-- src/backend/utils/misc/tzparser.c | 4 +-- src/backend/utils/mmgr/aset.c | 6 ++++- src/backend/utils/mmgr/mcxt.c | 11 +++----- src/backend/utils/mmgr/portalmem.c | 12 +++------ src/backend/utils/sort/tuplesort.c | 8 ++---- src/include/utils/memutils.h | 14 +++++++++- src/pl/plperl/plperl.c | 12 +++------ src/pl/plpgsql/src/pl_comp.c | 10 +++---- src/pl/plpgsql/src/pl_exec.c | 8 ++---- src/pl/plpython/plpy_cursorobject.c | 8 ++---- src/pl/plpython/plpy_main.c | 8 ++---- src/pl/plpython/plpy_procedure.c | 4 +-- src/pl/plpython/plpy_spi.c | 8 ++---- src/pl/plpython/plpy_typeio.c | 8 ++---- src/pl/tcl/pltcl.c | 4 +-- 99 files changed, 206 insertions(+), 522 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Add macros to make AllocSetContextCreate() calls simpler and saf @ 2016-08-27 21:50 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2016-08-27 21:50 UTC (permalink / raw) To: pgsql-committers Add macros to make AllocSetContextCreate() calls simpler and safer. I found that half a dozen (nearly 5%) of our AllocSetContextCreate calls had typos in the context-sizing parameters. While none of these led to especially significant problems, they did create minor inefficiencies, and it's now clear that expecting people to copy-and-paste those calls accurately is not a great idea. Let's reduce the risk of future errors by introducing single macros that encapsulate the common use-cases. Three such macros are enough to cover all but two special-purpose contexts; those two calls can be left as-is, I think. While this patch doesn't in itself improve matters for third-party extensions, it doesn't break anything for them either, and they can gradually adopt the simplified notation over time. In passing, change TopMemoryContext to use the default allocation parameters. Formerly it could only be extended 8K at a time. That was probably reasonable when this code was written; but nowadays we create many more contexts than we did then, so that it's not unusual to have a couple hundred K in TopMemoryContext, even without considering various dubious code that sticks other things there. There seems no good reason not to let it use growing blocks like most other contexts. Back-patch to 9.6, mostly because that's still close enough to HEAD that it's easy to do so, and keeping the branches in sync can be expected to avoid some future back-patching pain. The bugs fixed by these changes don't seem to be significant enough to justify fixing them further back. Discussion: <21072.1472321324@sss.pgh.pa.us> Branch ------ REL9_6_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/b9fe6cbc81ea120a39be755f23d6615486c11618 Modified Files -------------- contrib/bloom/blinsert.c | 8 ++---- contrib/dblink/dblink.c | 4 +-- contrib/file_fdw/file_fdw.c | 4 +-- contrib/pg_trgm/trgm_regexp.c | 4 +-- contrib/postgres_fdw/postgres_fdw.c | 20 ++++---------- contrib/sepgsql/uavc.c | 6 ++--- contrib/test_decoding/test_decoding.c | 4 +-- src/backend/access/brin/brin.c | 16 +++-------- src/backend/access/brin/brin_tuple.c | 4 +-- src/backend/access/common/printtup.c | 4 +-- src/backend/access/gin/ginbtree.c | 4 +-- src/backend/access/gin/ginfast.c | 4 +-- src/backend/access/gin/gininsert.c | 12 +++------ src/backend/access/gin/ginscan.c | 8 ++---- src/backend/access/gin/ginvacuum.c | 4 +-- src/backend/access/gin/ginxlog.c | 5 ++-- src/backend/access/gist/gist.c | 8 ++---- src/backend/access/gist/gistscan.c | 8 ++---- src/backend/access/heap/rewriteheap.c | 4 +-- src/backend/access/nbtree/nbtree.c | 4 +-- src/backend/access/nbtree/nbtutils.c | 6 ++--- src/backend/access/spgist/spginsert.c | 8 ++---- src/backend/access/spgist/spgscan.c | 4 +-- src/backend/access/spgist/spgxlog.c | 4 +-- src/backend/access/transam/multixact.c | 6 ++--- src/backend/access/transam/parallel.c | 12 +++------ src/backend/access/transam/xact.c | 8 ++---- src/backend/access/transam/xlog.c | 4 +-- src/backend/access/transam/xloginsert.c | 4 +-- src/backend/bootstrap/bootstrap.c | 4 +-- src/backend/catalog/objectaddress.c | 4 +-- src/backend/commands/analyze.c | 12 +++------ src/backend/commands/cluster.c | 4 +-- src/backend/commands/copy.c | 8 ++---- src/backend/commands/event_trigger.c | 8 ++---- src/backend/commands/indexcmds.c | 4 +-- src/backend/commands/policy.c | 4 +-- src/backend/commands/trigger.c | 8 ++---- src/backend/commands/vacuum.c | 4 +-- src/backend/executor/execUtils.c | 12 +++------ src/backend/executor/functions.c | 4 +-- src/backend/executor/nodeFunctionscan.c | 4 +-- src/backend/executor/nodeHash.c | 8 ++---- src/backend/executor/nodeRecursiveunion.c | 8 ++---- src/backend/executor/nodeSetOp.c | 8 ++---- src/backend/executor/nodeSubplan.c | 8 ++---- src/backend/executor/nodeUnique.c | 4 +-- src/backend/executor/nodeWindowAgg.c | 18 +++++-------- src/backend/executor/spi.c | 23 +++++----------- src/backend/executor/tqueue.c | 4 +-- src/backend/libpq/be-fsstubs.c | 4 +-- src/backend/libpq/hba.c | 14 +++------- src/backend/optimizer/geqo/geqo_eval.c | 4 +-- src/backend/optimizer/util/clauses.c | 8 ++---- src/backend/postmaster/autovacuum.c | 24 +++++------------ src/backend/postmaster/bgwriter.c | 4 +-- src/backend/postmaster/checkpointer.c | 4 +-- src/backend/postmaster/pgstat.c | 4 +-- src/backend/postmaster/postmaster.c | 4 +-- src/backend/postmaster/walwriter.c | 4 +-- src/backend/replication/logical/logical.c | 6 ++--- src/backend/replication/logical/reorderbuffer.c | 6 ++--- src/backend/replication/logical/snapbuild.c | 4 +-- src/backend/replication/walsender.c | 4 +-- src/backend/storage/buffer/localbuf.c | 4 +-- src/backend/storage/file/reinit.c | 4 +-- src/backend/storage/lmgr/lwlock.c | 4 +-- src/backend/storage/smgr/md.c | 10 +++---- src/backend/tcop/postgres.c | 8 ++---- src/backend/tsearch/spell.c | 4 +-- src/backend/utils/adt/array_expanded.c | 4 +-- src/backend/utils/adt/arrayfuncs.c | 8 ++---- src/backend/utils/adt/jsonfuncs.c | 16 +++-------- src/backend/utils/adt/xml.c | 6 ++--- src/backend/utils/cache/catcache.c | 4 +-- src/backend/utils/cache/evtcache.c | 4 +-- src/backend/utils/cache/plancache.c | 35 ++++++++----------------- src/backend/utils/cache/relcache.c | 18 +++---------- src/backend/utils/cache/ts_cache.c | 4 +-- src/backend/utils/cache/typcache.c | 8 ++---- src/backend/utils/fmgr/funcapi.c | 4 +-- src/backend/utils/hash/dynahash.c | 4 +-- src/backend/utils/init/postinit.c | 4 +-- src/backend/utils/misc/guc-file.l | 4 +-- src/backend/utils/misc/tzparser.c | 4 +-- src/backend/utils/mmgr/aset.c | 6 ++++- src/backend/utils/mmgr/mcxt.c | 11 +++----- src/backend/utils/mmgr/portalmem.c | 12 +++------ src/backend/utils/sort/tuplesort.c | 8 ++---- src/include/utils/memutils.h | 14 +++++++++- src/pl/plperl/plperl.c | 12 +++------ src/pl/plpgsql/src/pl_comp.c | 10 +++---- src/pl/plpgsql/src/pl_exec.c | 4 +-- src/pl/plpython/plpy_cursorobject.c | 8 ++---- src/pl/plpython/plpy_main.c | 8 ++---- src/pl/plpython/plpy_procedure.c | 4 +-- src/pl/plpython/plpy_spi.c | 8 ++---- src/pl/plpython/plpy_typeio.c | 8 ++---- src/pl/tcl/pltcl.c | 4 +-- 99 files changed, 205 insertions(+), 519 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2016-08-27 21:50 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-08-27 21:50 pgsql: Add macros to make AllocSetContextCreate() calls simpler and saf Tom Lane <tgl@sss.pgh.pa.us> 2016-08-27 21:50 pgsql: Add macros to make AllocSetContextCreate() calls simpler and saf Tom Lane <tgl@sss.pgh.pa.us>
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