pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Get rid of artificial restriction on hash table sizes on Windows 3+ messages / 1 participants [nested] [flat]
* pgsql: Get rid of artificial restriction on hash table sizes on Windows @ 2021-07-25 18:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2021-07-25 18:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Get rid of artificial restriction on hash table sizes on Windows. The point of introducing the hash_mem_multiplier GUC was to let users reproduce the old behavior of hash aggregation, i.e. that it could use more than work_mem at need. However, the implementation failed to get the job done on Win64, where work_mem is clamped to 2GB to protect various places that calculate memory sizes using "long int". As written, the same clamp was applied to hash_mem. This resulted in severe performance regressions for queries requiring a bit more than 2GB for hash aggregation, as they now spill to disk and there's no way to stop that. Getting rid of the work_mem restriction seems like a good idea, but it's a big job and could not conceivably be back-patched. However, there's only a fairly small number of places that are concerned with the hash_mem value, and it turns out to be possible to remove the restriction there without too much code churn or any ABI breaks. So, let's do that for now to fix the regression, and leave the larger task for another day. This patch does introduce a bit more infrastructure that should help with the larger task, namely pg_bitutils.h support for working with size_t values. Per gripe from Laurent Hasson. Back-patch to v13 where the behavior change came in. Discussion: https://postgr.es/m/997817.1627074924@sss.pgh.pa.us Discussion: https://postgr.es/m/MN2PR15MB25601E80A9B6D1BA6F592B1985E39@MN2PR15MB2560.namprd15.prod.outlook.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/28d936031a86d94806c6604480ff3f3f169b371c Modified Files -------------- src/backend/executor/execGrouping.c | 6 +- src/backend/executor/nodeAgg.c | 42 ++++++----- src/backend/executor/nodeHash.c | 126 +++++++++++++++++---------------- src/backend/executor/nodeMemoize.c | 2 +- src/backend/optimizer/path/costsize.c | 7 +- src/backend/optimizer/plan/planner.c | 6 +- src/backend/optimizer/plan/subselect.c | 6 +- src/backend/optimizer/prep/prepunion.c | 8 +-- src/backend/optimizer/util/pathnode.c | 3 +- src/backend/storage/ipc/shm_mq.c | 6 +- src/include/miscadmin.h | 2 +- src/include/port/pg_bitutils.h | 50 ++++++++++++- 12 files changed, 153 insertions(+), 111 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Get rid of artificial restriction on hash table sizes on Windows @ 2021-07-25 18:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2021-07-25 18:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Get rid of artificial restriction on hash table sizes on Windows. The point of introducing the hash_mem_multiplier GUC was to let users reproduce the old behavior of hash aggregation, i.e. that it could use more than work_mem at need. However, the implementation failed to get the job done on Win64, where work_mem is clamped to 2GB to protect various places that calculate memory sizes using "long int". As written, the same clamp was applied to hash_mem. This resulted in severe performance regressions for queries requiring a bit more than 2GB for hash aggregation, as they now spill to disk and there's no way to stop that. Getting rid of the work_mem restriction seems like a good idea, but it's a big job and could not conceivably be back-patched. However, there's only a fairly small number of places that are concerned with the hash_mem value, and it turns out to be possible to remove the restriction there without too much code churn or any ABI breaks. So, let's do that for now to fix the regression, and leave the larger task for another day. This patch does introduce a bit more infrastructure that should help with the larger task, namely pg_bitutils.h support for working with size_t values. Per gripe from Laurent Hasson. Back-patch to v13 where the behavior change came in. Discussion: https://postgr.es/m/997817.1627074924@sss.pgh.pa.us Discussion: https://postgr.es/m/MN2PR15MB25601E80A9B6D1BA6F592B1985E39@MN2PR15MB2560.namprd15.prod.outlook.com Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b154ee63bb659ce280d486db6bbbe77ddec105c5 Modified Files -------------- src/backend/executor/execGrouping.c | 6 +- src/backend/executor/nodeAgg.c | 42 +++++----- src/backend/executor/nodeHash.c | 144 +++++++++++++++++++-------------- src/backend/executor/nodeMemoize.c | 2 +- src/backend/optimizer/path/costsize.c | 7 +- src/backend/optimizer/plan/planner.c | 6 +- src/backend/optimizer/plan/subselect.c | 6 +- src/backend/optimizer/prep/prepunion.c | 8 +- src/backend/optimizer/util/pathnode.c | 3 +- src/include/miscadmin.h | 1 + src/include/port/pg_bitutils.h | 50 +++++++++++- 11 files changed, 172 insertions(+), 103 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Get rid of artificial restriction on hash table sizes on Windows @ 2021-07-25 18:03 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2021-07-25 18:03 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Get rid of artificial restriction on hash table sizes on Windows. The point of introducing the hash_mem_multiplier GUC was to let users reproduce the old behavior of hash aggregation, i.e. that it could use more than work_mem at need. However, the implementation failed to get the job done on Win64, where work_mem is clamped to 2GB to protect various places that calculate memory sizes using "long int". As written, the same clamp was applied to hash_mem. This resulted in severe performance regressions for queries requiring a bit more than 2GB for hash aggregation, as they now spill to disk and there's no way to stop that. Getting rid of the work_mem restriction seems like a good idea, but it's a big job and could not conceivably be back-patched. However, there's only a fairly small number of places that are concerned with the hash_mem value, and it turns out to be possible to remove the restriction there without too much code churn or any ABI breaks. So, let's do that for now to fix the regression, and leave the larger task for another day. This patch does introduce a bit more infrastructure that should help with the larger task, namely pg_bitutils.h support for working with size_t values. Per gripe from Laurent Hasson. Back-patch to v13 where the behavior change came in. Discussion: https://postgr.es/m/997817.1627074924@sss.pgh.pa.us Discussion: https://postgr.es/m/MN2PR15MB25601E80A9B6D1BA6F592B1985E39@MN2PR15MB2560.namprd15.prod.outlook.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2b8f3f5a7c0ede24903782fcffe2553fec01bfbe Modified Files -------------- src/backend/executor/execGrouping.c | 6 +- src/backend/executor/nodeAgg.c | 42 +++++----- src/backend/executor/nodeHash.c | 144 +++++++++++++++++++-------------- src/backend/optimizer/path/costsize.c | 5 +- src/backend/optimizer/plan/planner.c | 6 +- src/backend/optimizer/plan/subselect.c | 3 +- src/backend/optimizer/prep/prepunion.c | 8 +- src/backend/optimizer/util/pathnode.c | 3 +- src/include/miscadmin.h | 1 + src/include/port/pg_bitutils.h | 50 +++++++++++- 10 files changed, 169 insertions(+), 99 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-07-25 18:03 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-07-25 18:03 pgsql: Get rid of artificial restriction on hash table sizes on Windows Tom Lane <tgl@sss.pgh.pa.us> 2021-07-25 18:03 pgsql: Get rid of artificial restriction on hash table sizes on Windows Tom Lane <tgl@sss.pgh.pa.us> 2021-07-25 18:03 pgsql: Get rid of artificial restriction on hash table sizes on Windows 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