diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-09-21 10:31:58 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-09-21 10:31:58 +0900 |
commit | 43c1c4f65eab77bcfc4f535a7e9ac0421e0cf2a5 (patch) | |
tree | 225d15405ade653c8e3cd5aa28c15a64e7ba2154 /src/backend/utils/misc | |
parent | 5e6716cde5749aea506dd3f30b099b6e9b4c5af8 (diff) | |
download | postgresql-43c1c4f65eab77bcfc4f535a7e9ac0421e0cf2a5.tar.gz postgresql-43c1c4f65eab77bcfc4f535a7e9ac0421e0cf2a5.zip |
Introduce GUC shared_memory_size_in_huge_pages
This runtime-computed GUC shows the number of huge pages required
for the server's main shared memory area, taking advantage of the
work done in 0c39c29 and 0bd305e. This is useful for users to estimate
the amount of huge pages required for a server as it becomes possible to
do an estimation without having to start the server and potentially
allocate a large chunk of shared memory.
The number of huge pages is calculated based on the existing GUC
huge_page_size if set, or by using the system's default by looking at
/proc/meminfo on Linux. There is nothing new here as this commit reuses
the existing calculation methods, and just exposes this information
directly to the user. The routine calculating the huge page size is
refactored to limit the number of files with platform-specific flags.
This new GUC's name was the most popular choice based on the discussion
done. This is only supported on Linux.
I have taken the time to test the change on Linux, Windows and MacOS,
though for the last two ones large pages are not supported. The first
one calculates correctly the number of pages depending on the existing
GUC huge_page_size or the system's default.
Thanks to Andres Freund, Robert Haas, Kyotaro Horiguchi, Tom Lane,
Justin Pryzby (and anybody forgotten here) for the discussion.
Author: Nathan Bossart
Discussion: https://postgr.es/m/F2772387-CE0F-46BF-B5F1-CC55516EB885@amazon.com
Diffstat (limited to 'src/backend/utils/misc')
-rw-r--r-- | src/backend/utils/misc/guc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index a6e4fcc24ed..d2ce4a84506 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -665,6 +665,7 @@ static int max_identifier_length; static int block_size; static int segment_size; static int shared_memory_size_mb; +static int shared_memory_size_in_huge_pages; static int wal_block_size; static bool data_checksums; static bool integer_datetimes; @@ -2350,6 +2351,17 @@ static struct config_int ConfigureNamesInt[] = }, { + {"shared_memory_size_in_huge_pages", PGC_INTERNAL, PRESET_OPTIONS, + gettext_noop("Shows the number of huge pages needed for the main shared memory area."), + gettext_noop("-1 indicates that the value could not be determined."), + GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_RUNTIME_COMPUTED + }, + &shared_memory_size_in_huge_pages, + -1, -1, INT_MAX, + NULL, NULL, NULL + }, + + { {"temp_buffers", PGC_USERSET, RESOURCES_MEM, gettext_noop("Sets the maximum number of temporary buffers used by each session."), NULL, |