Re: [PATCH] Use MAP_HUGETLB where supported (v3)

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Christian Kruse <christian(at)2ndQuadrant(dot)com>
Cc: Andres Freund <andres(at)2ndQuadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Use MAP_HUGETLB where supported (v3)
Date: 2014-02-26 12:34:43
Message-ID: 530DDF63.7020700@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 02/26/2014 10:35 AM, Christian Kruse wrote:
> On 25/02/14 19:28, Andres Freund wrote:
>> I think all that's needed is to cut the first paragraphs that generally
>> explain what huge pages are in some detail from the text and make sure
>> the later paragraphs don't refer to the earlier ones.
>
> Attached you will find a new version of the patch.

Thanks!

> huge_tlb_pages (enum)
>
> Enables/disables the use of huge TLB 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.
>
> 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 Section 17.4.4.
>
> With huge_tlb_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 off, huge pages will not be used.

That still says "The setting is ignored on other systems". That's not
quite true: as explained later in the section, if you set
huge_tlb_pages=on and the platform doesn't support it, the server will
refuse to start.

> 17.4.4. Linux huge TLB pages

This section looks good to me. I'm OK with the level of detail, although
maybe just a sentence or two about what huge TLB pages are and what
benefits they have would still be in order. How about adding something
like this as the first sentence:

"Using huge TLB 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 calculate 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

That's good advice, but perhaps s/calculate/estimate/. It's just an
approximation, after all.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2014-02-26 13:07:51 Re: pgsql: Allow time delayed standbys and recovery
Previous Message Pavel Golub 2014-02-26 11:20:10 Re: 9.5: UPDATE/DELETE .. ORDER BY .. LIMIT ..