DatabaseOracle Database

What is “hugepages” and how it affects my Oracle database.

Photo by Olga Tutunaru on Unsplash

Hugepages is a feature of the Linux Kernel for efficient memory management; an understanding of its concept helps a DBA with proactive tuning of database memory. Before we dive into the concept of hugepages, let’s quickly understand what is “Virtual memory” and “Paging” are and how they affect “Translation Lookaside Buffer or TLB”

Virtual memory is a abstraction between a physical RAM on a computer and the process running on it. It allows each server process to have it’s own private address space pointing to physical RAM. If physical memory runs out it provides for disk storage to become an extension of memory which we call swapping or paging. Paging on the other hand is a mechanism which enables virtual memory to work. It divides virtual memory address space into equal chunks of sizes (default 4Kb on x84 systems) called pages , and physical memory into fixed size units called frames. The OS maintains a mapping between virtual pages and physical frames , called the PAGE TABLE.

When CPU access memory using a virtual address , it needs to translate address into a physical address by looking through the page table. This lookup could however be slow as the page table resides in main memory RAM. To speed up access CPU uses TLB to cache recent virtual address to physical address mappings. TLB is cached in the CPU and CPU first looks up in the TLB to find the mapping , if not then it searches the page table and updates TLB with its recent lookup.

Now that you have understood the memory lookup imagine what if a page could be of bigger size lets say 2Mb or 1Gb instead of default 4Kb. If pages are bigger then page table would be small which would result in faster lookup hence improving our TLB hit ratio. A simple bigger page size would improve the performance of memory retrieval and we call these bigger page sizes “HugePages”. Enabling Hugepages provide an enhanced performance to memory intensive applications like a OLAP or OLTP oracle database , or an In memory database. Oracle even recommends to enable Hugepages if your sga is greater than 8GB .

While using Hugepages on a Oracle Database host, one has to remember that  Automatic Memory Management (AMM) is not compatible with Linux HugePages. Instead, Automatic Shared Memory Management and Automatic PGA Management should be used as they are compatible with HugePage.

TL;DR unset the memory_target and memory_max_target parameters and configure sga_target and pga_target parameters. Refer to the official documentation on how to enable hugepages here .

References:

1. https://docs.oracle.com/database/121/UNXAR/appi_vlm.htm#UNXAR391

2. https://www.netdata.cloud/blog/understanding-huge-pages

3. https://oracle-base.com/articles/linux/configuring-huge-pages-for-oracle-on-linux-64

Leave a Reply