Using HugePages for Linux with Oracle: What You Need to Know
Computer memory is managed in blocks of storage known as pages, which have a predetermined size that depends on the computer’s architecture. These pages are organized using a page table, which is a data structure that links virtual memory addresses to their physical location in memory.
As companies store more and more information in their enterprise databases, using large amounts of memory becomes slower and more inefficient as the default memory page size remains the same.
To address this issue, several flavors of the Linux operating system have implemented a feature known as HugePages–so what exactly do you need to know about them, and how do they impact your Oracle environment?
What are HugePages and Why Do They Matter?
HugePages are a feature in the Linux operating system that allow the Linux kernel to manage large pages of memory.
The x86 and x86-64 instruction sets have standard page sizes of 4 kilobytes, while the IA-64 instruction set has a standard page size of 16 kilobytes. HugePages significantly enhance these storage capabilities: they are 4 megabytes in size on x86, 2 megabytes in size on x86-64, and 256 megabytes on IA-64.
HugePages are allocated when the computer boots, and they remain pinned in memory. This means that the kernel swap daemon (kswapd) does not need to manage them, and the Linux kernel does not need to perform page table lookup for them.
In other words, HugePages enable you to dramatically reduce your page table overhead, especially when dealing with large System Global Areas (SGAs). They reduce the likelihood of bottlenecks when accessing page tables, thereby providing a noticeable increase in performance.
When Should You Use HugePages?
According to Oracle, you should enable the HugePages feature if you have a system with more than 16 gigabytes of memory running Oracle databases with a total SGA larger than 8 gigabytes. Realistically, however, any database with an SGA size of 100 megabytes or more can benefit from using HugePages.
HugePages are a “use it or lose it” feature, so you should make sure that they aren’t going to waste in your Oracle environment. Below, we provide a simple script that you can use to determine if HugePages are enabled and, if so, whether any of them are going unused.
You can enable HugePages by first setting the Linux initialization parameter vm.nr_hugepages to the number of pages that you want to make available for the Oracle Database SGA, and then rebooting the server.
Note that Oracle’s Automatic Memory Management (AMM) feature is not compatible with HugePages in Oracle Database 11g and later. You must disable AMM in order to be able to use HugePages.
Disabling Transparent HugePages
Transparent HugePages are similar to HugePages, but have one crucial point of distinction. While HugePages must be preallocated at boot, Transparent HugePages are set up dynamically at run time by the khugepaged thread in the Linux kernel.
Unfortunately, Transparent HugePages are known to cause issues such as unexpected node reboots and performance problems with Oracle Real Application Clusters (RAC). They may also cause problems or delays even in a single-instance database environment.
Transparent HugePages are implemented and enabled by default beginning with Red Hat Enterprise Linux 6, SUSE 11, Oracle Linux 6, and Unbreakable Enterprise Kernel Release 2. Due to the difficulties listed above, however, Oracle recommends disabling Transparent HugePages on all Linux database servers running Oracle.
In order to determine whether transparent HugePages are in use, run the following command at the Linux command line:
$ grep -i hugepage /proc/meminfo
AnonHugePages: 6602752 kB
Hugepagesize: 2048 kB
In this example, you can see that HugePages are not in use, but that Transparent HugePages are. To disable Transparent HugePages, add the following to the kernel boot line in your /etc/grub.conf file and reboot the server:
The most important pieces of information that you should take away from this article are:
- If your database has an SGA size of 100 megabytes or greater, then you can likely benefit from using HugePages. However, Oracle suggests that you disable Transparent HugePages on any Linux database servers running Oracle.
- HugePages follow a “use it or lose it” paradigm, so make sure that you optimize your usage of HugePages.
- Automatic Memory Management (AMM) and HugePages are not compatible in Oracle 11g versions and later.
It’s 2015 and you can now establish totally respectable MS SQL DBA credibility just by mentioning you have been in the game since SQL Server version 9. You may even get the same gasps of shock from some colleagues that used to be reserved for the version 6 veterans.