Home > Workload Solutions > Oracle > Best Practices > AMD-Based Oracle Best Practices on Dell PowerEdge R740 and PowerMax 2000 > Linux Best Practices > Day Two Best Practices > Red Hat Enterprise Linux: HugePages
In this best practice we used Oracle scripts to implement HugePages in the Linux operating system.
Category | Operating System |
Product | Red Hat Enterprise Linux 8.3 |
Type of best practice | Performance Optimization |
Day and value | Day 2, Moderate Recommendation |
Overview
The default memory page size used by the Linux operating system is 4 KB. While the 4 KB works well for many applications, the Oracle Shared Global Area (SGA) memory pool can be very large. The memory size of the SGA is large because it supports components like the database buffer cache, shared pool, large pool, and many other memory pools. Thus, management of the SGA using 4 KB memory pages can cause excessive processing and wait times to access memory pages.
HugePages are the capability of the Linux administrator to configure the operating system to use 2 MB page sizes. The larger memory pages mean the operating system can manage less pages and access memory pages faster thus, optimizing memory management. The additional benefit of using HugePages is the larger pages cannot be swapped out to disk. Over time HugePages has become an accepted best practice that many Oracle systems use to optimize performance.
Recommendation
We implemented 2 MB HugePages in the Linux operating systems for all the Oracle databases and then tested the configuration by running an OLTP workload. Test results showed no changes for the following performance metrics:
Test results show moderate savings for:
HugePages optimizes the memory configuration of the Linux operating system. The optimized memory configuration did not improve NOPM, TPM, and IOPS.
Server CPU utilization showed a moderate decrease.
The benefit of HugePages is that the operating system manages fewer larger pages, which eases the management. The overall CPU utilization of the server showed a moderate savings when using HugePages. The savings in CPU utilization validates that HugePages optimizes page management.
DB File Sequential Read remained the same and Log File Parallel Write increased slightly as a result of the increases in NOPM and TPM.
Overall, HugePages optimized memory of the Linux operating system leading to improved performance and a decrease in CPU utilization. For these reasons we recommend implementing HugePages is a Day 2, Moderate recommended best practice.
Implementation Steps
To enable the Hugepages, complete the following steps:
$ grep Huge /proc/meminfo AnonHugePages: 0 kB ShmemHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 0 kB
* soft memlock 120,795,955 * hard memlock 120,795,955
$ ulimit -l 120795955
$ grep Hugepagesize /proc/meminfo
!/bin/bash # # hugepages_settings.sh # # Linux bash script to compute values for the # recommended HugePages/HugeTLB configuration # # Note: This script does calculation for all shared memory # segments available when the script is run, no matter it # is an Oracle RDBMS shared memory segment or not. # Check for the kernel version KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'` # Find out the HugePage size HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}` # Start from 1 pages to be on the safe side and guarantee 1 free HugePage NUM_PG=1 # Cumulative number of pages required to handle the running shared memory segments for SEG_BYTES in `ipcs -m | awk {'print $5'} | grep "[0-9][0-9]*"` do MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q` if [ $MIN_PG -gt 0 ]; then NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q` fi done # Finish with results case $KERN in '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`; echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;; '2.6'|'3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;; *) echo "Unrecognized kernel version $KERN. Exiting." ;; esac # End
$chmod +x hugepages_settings.sh
$./hugepages_settings.sh
# sysctl -w vm.nr_hugepages=value Check the available hugepages: $grep Huge /proc/meminfo
$grep Huge /proc/meminfo
Additional Resources
Oracle Database Online Documentations 12c, Huge Pages
Administering Oracle Database 19c on Linux: Overview of HugePages