Disabling the transparent hugepages
Understanding the transparent hugepages
Transparent hugepages is a Linux kernel feature intended to improve performance by making more efficient use of your processor’s memory-mapping hardware. This feature gives some applications a small performance boost, but can cause significant latency issues (to database engines for instance) or even apparent memory leaks at worst.
Note
Do not confuse transparent hugepages with explicit hugepages
While transparent hugepages are dynamically reassigned by the kernel to be reused by any compatible application, explicit hugepages are reserved for specific services and render inaccessible to other workloads in the system.
This chapter shows you how to disable the transparent hugepages because:
- There is no recommended setup for Proxmox VE about this feature.
- It may not be worth having it enabled in a small server setup (specially on the RAM side) like the one used in this guide.
- Can provoke serious latency issues in a system when it kicks in to compact fragmented RAM.
Important
Do not completely dismiss using transparent hugepages!
Remember that some applications may benefit from this feature, although they have to be built for it specifically.
Therefore, research the references found at the end of this chapter and carefully evaluate if your system’s workload can benefit from having transparent hugepages enabled.
Status of the transparent hugepages in your host
To check out the current status of the transparent hugepages in your standalone PVE node, log as your mgrsys user in a shell and execute:
$ cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] neverThe highlighted value is madvise, which means that transparent hugepages are enabled but only for applications that request it specifically.
There is other parameter that hints about the usage of transparent hugepages, AnonHugePages. To see its current value, execute the following command:
$ grep AnonHuge /proc/meminfo
AnonHugePages: 0 kBAt this point, no application has made use of transparent hugepages, so the value of AnonHugePages is 0 KiB.
Disabling the transparent hugepages
To switch the status of the transparent hugepages from madvise to never, you must modify the configuration of your Debian’s Grub boot system:
Open a shell as
mgrsys,cdto/etc/default/and make a backup of the originalgrubfile:$ cd /etc/default/ $ sudo cp grub grub.origEdit the
grubfile, modifying theGRUB_CMDLINE_LINUX=""line as follows:GRUB_CMDLINE_LINUX="transparent_hugepage=never"Update the grub and reboot the system:
$ sudo update-grub $ sudo rebootLog again as
mgrsysand check the current status of the transparent hugepages:$ cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never]The highlighted status should be
nevernow, as shown in the snippet above.
Relevant system paths
Directories
/etc/default
Files
/etc/default/grub/etc/default/grub.orig/proc/meminfo/sys/kernel/mm/transparent_hugepage/enabled
References
About transparent hugepages
Google Groups. mechanical-sympathy. failing to understand the issues with transparent huge paging
The mole is digging. Transparent Hugepages: measuring the performance impact
Blog for Database and System Administrators. Debian 10: How to disable transparent hugepages