diff options
author | Michael Paquier | 2021-09-21 01:31:58 +0000 |
---|---|---|
committer | Michael Paquier | 2021-09-21 01:31:58 +0000 |
commit | 43c1c4f65eab77bcfc4f535a7e9ac0421e0cf2a5 (patch) | |
tree | 225d15405ade653c8e3cd5aa28c15a64e7ba2154 /doc/src/sgml/runtime.sgml | |
parent | 5e6716cde5749aea506dd3f30b099b6e9b4c5af8 (diff) |
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/[email protected]
Diffstat (limited to 'doc/src/sgml/runtime.sgml')
-rw-r--r-- | doc/src/sgml/runtime.sgml | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index f1cbc1d9e92..d74d1ed7afa 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1442,17 +1442,14 @@ export PG_OOM_ADJUST_VALUE=0 with <varname>CONFIG_HUGETLBFS=y</varname> and <varname>CONFIG_HUGETLB_PAGE=y</varname>. You will also have to configure the operating system to provide enough huge pages of the desired size. - To estimate the number of huge pages needed, start - <productname>PostgreSQL</productname> without huge pages enabled and check - the postmaster's anonymous shared memory segment size, as well as the - system's default and supported huge page sizes, using the - <filename>/proc</filename> and <filename>/sys</filename> file systems. + To determine the number of huge pages needed, use the + <command>postgres</command> command to see the value of + <xref linkend="guc-shared-memory-size-in-huge-pages"/>. Note that the + server must be shut down to view this runtime-computed parameter. This might look like: <programlisting> -$ <userinput>head -1 $PGDATA/postmaster.pid</userinput> -4170 -$ <userinput>pmap 4170 | awk '/rw-s/ && /zero/ {print $2}'</userinput> -6490428K +$ <userinput>postgres -D $PGDATA -C shared_memory_size_in_huge_pages</userinput> +3170 $ <userinput>grep ^Hugepagesize /proc/meminfo</userinput> Hugepagesize: 2048 kB $ <userinput>ls /sys/kernel/mm/hugepages</userinput> @@ -1460,13 +1457,13 @@ hugepages-1048576kB hugepages-2048kB </programlisting> In this example the default is 2MB, but you can also explicitly request - either 2MB or 1GB with <xref linkend="guc-huge-page-size"/>. + either 2MB or 1GB with <xref linkend="guc-huge-page-size"/> to adapt + the number of pages calculated by + <varname>shared_memory_size_in_huge_pages</varname>. - Assuming <literal>2MB</literal> huge pages, - <literal>6490428</literal> / <literal>2048</literal> gives approximately - <literal>3169.154</literal>, so in this example we need at - least <literal>3170</literal> huge pages. A larger setting would be - appropriate if other programs on the machine also need huge pages. + While we need at least <literal>3170</literal> huge pages in this example, + a larger setting would be appropriate if other programs on the machine + also need huge pages. We can set this with: <programlisting> # <userinput>sysctl -w vm.nr_hugepages=3170</userinput> |