Native-Turbo
Overview
The code segment and data segment of a large program can reach hundreds of MB, and the TLB miss rate of key service processes is high. The size of the kernel page table affects the performance.
To facilitate the use of huge pages, the Native-Turbo feature enables the system to automatically use huge pages when loading programs. Huge pages can be used for code segments and data segments.
How to Use
Enable the feature.
This feature has two levels of switches.
sysctl fs.exec-use-hugetlb
determines whether to enable this feature in the system. (This command can only be run by the root user. The value0
indicates that this feature is disabled, and the value1
indicates that this feature is enabled. Other values are invalid.)If not enabled, this feature will not be used even if users set environment variables because the kernel will ignore related processes.
After this feature is enabled, common users can use the environment variable
HUGEPAGE_PROBE
to determine whether to use huge pages for running programs. If the value is1
, huge pages are used. If the value is not set, huge pages are not used.sysctl fs.exec-use-hugetlb=1 # The main program uses huge pages. export HUGEPAGE_PROBE=1 # The dynamic library uses huge pages.
You can also configure the environment variable
LD_HUGEPAGE_LIB=1
to force all segments to use huge pages.Mark the segments that need to use huge pages. By default, all segments are marked.
-x
only marks code segments.-d
clears existing marks.hugepageedit [-x] [-d] app
This tool is provided by the glibc-devel package.
Run the application.
./app
Restrictions
The program and dynamic library must be compiled in 2 MB alignment mode by adding the following GCC compilation parameters:
-zcommon-page-size=0x200000 -zmax-page-size=0x200000
Sufficient huge pages must be reserved before use. Otherwise, the program wil fail to be executed.
If the cgroup is used, pay attention to the
hugetlb
limit. If the limit is less than the number of required huge pages, the system may break down during running.The size of the process page table is changed to 2 MB. Therefore, the parameters invoked by the system such as
mprotect
must be aligned by 2 MB. Otherwise, the execution will fail.The LibcarePlus hot patch mechanism is not supported.
Huge pages cannot be shared among multiple processes because they will consume multiple times of memory.