HugePages is a linux kernel feature that is integrated into the linux kernel >= 2.6. Enabling HugePages makes it possible for the operating system to support memory pages greater than default size that is 4KB. It is useful for both 32bit and 64bit architecture. It improves system performance by allocating bigger size of Pages and reducing the amount of system resources to access them. Size of hugepage vary from 2MB to 256 MB. It depends on the kernel version and hardware architecture. Hugepage enable single page size from default 4K to 2M resulting least number of Pages to access. In addition to that the HugePages can not be swapped which force the SGA to stay on Physical memory rather than virtual.
Configure hugepages
Verify existing hugepage setting
grep -i huge /proc/meminfo
Create a file hugepage.sh with following contents
#!/bin/bash
# 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' | '3.10' | '4.1' ) echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
*) echo "Unrecognized kernel version $KERN. Exiting." ;;
esac
# End
Make the script file executable
chmod 755 hugepage.sh
Execute the script file
./hugepage.sh
Configure kernel parameter vm.nr_hugepages in sysctl.conf file. In this case will be increase huge page values by 1 or 2
vi /etc/sysctl.conf
vm.nr_hugepages=886
Execute following command to take the kernel paramenter into effect.
sysctl -p
Verify change with command below
grep -i huge /proc/meminfo
Modify memlock setting on /etc/security/limits.conf, the setting should be greater than or equal to the size of hugepage * number of hugepages
In our case 886 * 2048=1814528
Now force oracle to use hugepages only with oracle database parameter use_large_pages to only.
show parameter use_large_pages;
if the use_large_pages parameter is not set to true then alter it to true and restart the database.
if the use_large_pages parameter is not set to true then alter it to true and restart the database.
alter system set use_large_pages=TRUE scope=spfile;
shutdown immediate;
startup
No comments:
Post a Comment