Home > Workload Solutions > Oracle > Guides > Implementation Guide—Oracle Database 19c Best Practices on PowerStore > Red Hat Enterprise Linux: HugePages
In this best practice we used Oracle scripts to implement HugePages in the Linux operating system.
Overview
The Linux operating system default memory size is 4 KB. While this size 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 other 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 is a feature integrated into the Linux kernel 2.6. Enabling HugePages makes it possible for the operating system to support memory pages greater than the default. Using very large page sizes can improve system performance by reducing the amount of system resources required to access page table entries. For Oracle databases, using HugePages reduces the operating system maintenance of page states, and increases Translation Lookaside Buffer (TLB) hit ratio. Oracle recommends using HugePages on Linux platform installations to obtain the best performance for Oracle Databases.
Implementation 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
!/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
And execute this script to get the values for hugepages configuration:
# ./hugepages_settings.sh
vm.nr_hugepages=value
# sysctl -p
# grep Huge /proc/meminfo
Additional resources
Oracle® Database Administrator's Reference: 19c for Linux and UNIX System-Based Operating Systems