Recommendation to disable Linux kernel Transparent HugePages (THP) setting for performance improvement

Many Linux platforms have a memory management feature known as "Transparent HugePages", or "THP" for short, that's enabled by default. This is meant to transparently provide memory pages that are larger than the default 4k size. But over time, management of this can cause performance problems itself, especially with databases such as PostgreSQL.

If you find that AccuRev performance seems to have become slow on your Linux server (this FAQ does not apply to Windows or any non-Linux operating system) and there's no apparent reason, then disabling this system feature may help. If you wish, you can first check performance with the system 'top' command while you're having a slowdown occurrence. If the 'khugepaged' process shows up in the output or if you see a larger than normal percentage of CPU usage spent in "system", then THP could be the cause of the slowdown.

AccuRev recommends disabling THP if it is available on your Linux operating system. Check for the existence of the following directories to determine if you have this feature on your system:
-- Red Hat/CentOS: /sys/kernel/mm/redhat_transparent_hugepage
-- Ubuntu/Debian: /sys/kernel/mm/transparent_hugepage
If so, then running the following commands as root will temporarily disable THP on your system:
% echo "never" > full_pathname_above/enabled
% echo "never" > full_pathname_above/defrag
NOTE: Once you've changed the settings of the 'enabled' and 'defrag' files to "[never]", the system should slowly come back to more normal performance within several minutes.
To permanently disable THP across reboots, add the following to /etc/rc.local:
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
if test -f /sys/kernel/mm/redhat_transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
To verify that THP has been disabled, a 'cat' of the "enabled" and "defrag" files will display what state is currently active in brackets. For instance:
% cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
% cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
In the above output, "[never]" indicates that THP is disabled.
For further questions, contact the Micro Focus SupportLine.
Comment List
Related Discussions