Home Explore Blog CI



postgresql

26th chunk of `doc/src/sgml/config.sgml`
049e46152b7ce53922856f03fe8f675cc0771cdedfb8e9a20000000100000fb1
   <indexterm>
       <primary><varname>huge_pages</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        Controls whether huge pages are requested for the main shared memory
        area. Valid values are <literal>try</literal> (the default),
        <literal>on</literal>, and <literal>off</literal>.  With
        <varname>huge_pages</varname> set to <literal>try</literal>, the
        server will try to request huge pages, but fall back to the default if
        that fails. With <literal>on</literal>, failure to request huge pages
        will prevent the server from starting up. With <literal>off</literal>,
        huge pages will not be requested. The actual state of huge pages is
        indicated by the server variable
        <xref linkend="guc-huge-pages-status"/>.
       </para>

       <para>
        At present, this setting is supported only on Linux and Windows. The
        setting is ignored on other systems when set to
        <literal>try</literal>.  On Linux, it is only supported when
        <varname>shared_memory_type</varname> is set to <literal>mmap</literal>
        (the default).
       </para>

       <para>
        The use of huge pages results in smaller page tables and less CPU time
        spent on memory management, increasing performance. For more details about
        using huge pages on Linux, see <xref linkend="linux-huge-pages"/>.
       </para>

       <para>
        Huge pages are known as large pages on Windows.  To use them, you need to
        assign the user right <quote>Lock pages in memory</quote> to the Windows user account
        that runs <productname>PostgreSQL</productname>.
        You can use Windows Group Policy tool (gpedit.msc) to assign the user right
        <quote>Lock pages in memory</quote>.
        To start the database server on the command prompt as a standalone process,
        not as a Windows service, the command prompt must be run as an administrator or
        User Access Control (UAC) must be disabled. When the UAC is enabled, the normal
        command prompt revokes the user right <quote>Lock pages in memory</quote> when started.
       </para>

       <para>
        Note that this setting only affects the main shared memory area.
        Operating systems such as Linux, FreeBSD, and Illumos can also use
        huge pages (also known as <quote>super</quote> pages or
        <quote>large</quote> pages) automatically for normal memory
        allocation, without an explicit request from
        <productname>PostgreSQL</productname>. On Linux, this is called
        <quote>transparent huge pages</quote><indexterm><primary>transparent
        huge pages</primary></indexterm> (THP). That feature has been known to
        cause performance degradation with
        <productname>PostgreSQL</productname> for some users on some Linux
        versions, so its use is currently discouraged (unlike explicit use of
        <varname>huge_pages</varname>).
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-huge-page-size" xreflabel="huge_page_size">
      <term><varname>huge_page_size</varname> (<type>integer</type>)
      <indexterm>
       <primary><varname>huge_page_size</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        Controls the size of huge pages, when they are enabled with
        <xref linkend="guc-huge-pages"/>.
        The default is zero (<literal>0</literal>).
        When set to <literal>0</literal>, the default huge page size on the
        system will be used. This parameter can only be set at server start.
       </para>
       <para>
        Some commonly available page sizes on modern 64 bit server architectures include:
        <literal>2MB</literal> and <literal>1GB</literal> (Intel and AMD), <literal>16MB</literal> and
        <literal>16GB</literal> (IBM POWER), and <literal>64kB</literal>, <literal>2MB</literal>,

Title: Detailed Configuration of Huge Pages and Huge Page Size
Summary
This section provides further details on configuring huge pages in PostgreSQL. It explains the functionality of the `huge_pages` setting on Linux and Windows, including how to enable them and potential performance benefits like smaller page tables and reduced memory management overhead. It also cautions against using transparent huge pages (THP) on Linux due to potential performance issues. Furthermore, it introduces `huge_page_size`, which allows control over the size of huge pages when they are enabled. Common page sizes are listed.