From f8ce16d0d2645f3e223b1a68cd8f6b2fa3d56627 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 3 Mar 2014 20:52:48 +0200 Subject: Rename huge_tlb_pages to huge_pages, and improve docs. Christian Kruse --- doc/src/sgml/config.sgml | 24 ++++++++++------------ doc/src/sgml/runtime.sgml | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 14 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index cf11306f6cb..065c1dbdcf0 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1166,35 +1166,31 @@ include 'filename' - - huge_tlb_pages (enum) + + huge_pages (enum) - huge_tlb_pages configuration parameter + huge_pages configuration parameter - Enables/disables the use of huge TLB pages. Valid values are + Enables/disables the use of huge memory pages. Valid values are try (the default), on, and off. - At present, this feature is supported only on Linux. The setting - is ignored on other systems. + At present, this feature is supported only on Linux. The setting is + ignored on other systems when set to try. - The use of huge TLB pages results in smaller page tables and - less CPU time spent on memory management, increasing performance. For - more details, see - the Debian wiki. - Remember that you will need at least shared_buffers / huge page size + - 1 huge TLB pages. So for example for a system with 6GB shared buffers - and a hugepage size of 2kb of you will need at least 3156 huge pages. + The use of huge pages results in smaller page tables and less CPU time + spent on memory management, increasing performance. For more details, + see . - With huge_tlb_pages set to try, + With huge_pages set to try, the server will try to use huge pages, but fall back to using normal allocation if that fails. With on, failure to use huge pages will prevent the server from starting up. With diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index bbb808fecb0..7f4a2358c45 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1307,6 +1307,57 @@ echo -1000 > /proc/self/oom_score_adj + + + Linux huge pages + + + Using huge pages reduces overhead when using large contiguous chunks of + memory, like PostgreSQL does. To enable this + feature in PostgreSQL you need a kernel + with CONFIG_HUGETLBFS=y and + CONFIG_HUGETLB_PAGE=y. You also have to tune the system + setting vm.nr_hugepages. To estimate the number of + necessary huge pages start PostgreSQL without + huge pages enabled and check the VmPeak value from the + proc filesystem: + +$ head -1 /path/to/data/directory/postmaster.pid +4170 +$ grep ^VmPeak /proc/4170/status +VmPeak: 6490428 kB + + 6490428 / 2048 + (PAGE_SIZE is 2MB in this case) are + roughly 3169.154 huge pages, so you will need at + least 3170 huge pages: + +$ sysctl -w vm.nr_hugepages=3170 + + Sometimes the kernel is not able to allocate the desired number of huge + pages, so it might be necessary to repeat that command or to reboot. Don't + forget to add an entry to /etc/sysctl.conf to persist + this setting through reboots. + + + + The default behavior for huge pages in + PostgreSQL is to use them when possible and + to fallback to normal pages when failing. To enforce the use of huge + pages, you can set + huge_pages + to on. Note that in this case + PostgreSQL will fail to start if not enough huge + pages are available. + + + + For a detailed description of the Linux huge + pages feature have a look + at https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt. + + + -- cgit v1.2.3