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

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

PROBLEM:
 
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.
SOLUTION:

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
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/redhat_transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
fi
====================
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.

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2015-05-04 18:36
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.