aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/aio/aio_init.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2025-03-19 11:40:56 +1300
committerThomas Munro <tmunro@postgresql.org>2025-03-19 15:23:54 +1300
commit10f6646847515b1ab02735c24b04abaf1996f65f (patch)
treee49ca63aec12d99997f4fa91a6d4e3a11dbbe858 /src/backend/storage/aio/aio_init.c
parent17d8bba6dad12e14a7cafca9ef5eef21e577e9c3 (diff)
downloadpostgresql-10f6646847515b1ab02735c24b04abaf1996f65f.tar.gz
postgresql-10f6646847515b1ab02735c24b04abaf1996f65f.zip
Introduce io_max_combine_limit.
The existing io_combine_limit can be changed by users. The new io_max_combine_limit is fixed at server startup time, and functions as a silent clamp on the user setting. That in itself is probably quite useful, but the primary motivation is: aio_init.c allocates shared memory for all asynchronous IOs including some per-block data, and we didn't want to waste memory you'd never used by assuming they could be up to PG_IOV_MAX. This commit already halves the size of 'AioHandleIov' and 'AioHandleData'. A follow-up commit can now expand PG_IOV_MAX without affecting that. Since our GUC system doesn't support dependencies or cross-checks between GUCs, the user-settable one now assigns a "raw" value to io_combine_limit_guc, and the lower of io_combine_limit_guc and io_max_combine_limit is maintained in io_combine_limit. Reviewed-by: Andres Freund <andres@anarazel.de> (earlier version) Discussion: https://postgr.es/m/CA%2BhUKG%2B2T9p-%2BzM6Eeou-RAJjTML6eit1qn26f9twznX59qtCA%40mail.gmail.com
Diffstat (limited to 'src/backend/storage/aio/aio_init.c')
-rw-r--r--src/backend/storage/aio/aio_init.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/backend/storage/aio/aio_init.c b/src/backend/storage/aio/aio_init.c
index 4e405ce7ca8..2ede7e80b65 100644
--- a/src/backend/storage/aio/aio_init.c
+++ b/src/backend/storage/aio/aio_init.c
@@ -18,6 +18,7 @@
#include "storage/aio.h"
#include "storage/aio_internal.h"
#include "storage/aio_subsys.h"
+#include "storage/bufmgr.h"
#include "storage/io_worker.h"
#include "storage/ipc.h"
#include "storage/proc.h"
@@ -72,15 +73,9 @@ AioHandleShmemSize(void)
static Size
AioHandleIOVShmemSize(void)
{
- /*
- * Each IO handle can have an PG_IOV_MAX long iovec.
- *
- * XXX: Right now the amount of space available for each IO is PG_IOV_MAX.
- * While it's tempting to use the io_combine_limit GUC, that's
- * PGC_USERSET, so we can't allocate shared memory based on that.
- */
+ /* each IO handle can have up to io_max_combine_limit iovec objects */
return mul_size(sizeof(struct iovec),
- mul_size(mul_size(PG_IOV_MAX, AioProcs()),
+ mul_size(mul_size(io_max_combine_limit, AioProcs()),
io_max_concurrency));
}
@@ -89,7 +84,7 @@ AioHandleDataShmemSize(void)
{
/* each buffer referenced by an iovec can have associated data */
return mul_size(sizeof(uint64),
- mul_size(mul_size(PG_IOV_MAX, AioProcs()),
+ mul_size(mul_size(io_max_combine_limit, AioProcs()),
io_max_concurrency));
}
@@ -160,7 +155,7 @@ AioShmemInit(void)
bool found;
uint32 io_handle_off = 0;
uint32 iovec_off = 0;
- uint32 per_backend_iovecs = io_max_concurrency * PG_IOV_MAX;
+ uint32 per_backend_iovecs = io_max_concurrency * io_max_combine_limit;
pgaio_ctl = (PgAioCtl *)
ShmemInitStruct("AioCtl", AioCtlShmemSize(), &found);
@@ -213,7 +208,7 @@ AioShmemInit(void)
ConditionVariableInit(&ioh->cv);
dclist_push_tail(&bs->idle_ios, &ioh->node);
- iovec_off += PG_IOV_MAX;
+ iovec_off += io_max_combine_limit;
}
}