What are those pages and why would I want them to be huge?
When a process uses some memory, the CPU is marking the RAM as used by that process. For efficiency, the CPU allocate RAM by chunks of 4K bytes (it’s the default value on many platforms). Those chunks are named pages. Those pages can be swapped to disk, etc.
Since the process address space are virtual, the CPU and the operating system have to remember which page belong to which process, and where it is stored.
Obviously, the more pages you have, the more time it takes to find where the memory is mapped. When a process uses 1GB of memory, that’s 262144 entries to look up (1GB / 4K). If one Page Table Entry consume 8bytes, that’s 2MB (262144 * 8) to look-up.
How can I enable them?
The size of the huge pages in linux may change depending on the arch you are on
|Architecture||huge page size|
|i386||4K and 4M (2M in PAE mode)|
|ia64||4K, 8K, 64K, 256K, 1M, 4M, 16M, 256M|
|ppc64||4K and 16M|
You need to take the number below as a base
and the calculate how much kB you want to dedicate to the process (the system will not be able to use them anymore, caveat!!)
Is used for a runtime change (will disappear at reboot time).
To have a persistent change you have to use
You can the check with
Now you have to configure which user will be used for the huge pages (it will own the process of the app you want to use them with) in the /etc/security/limits.conf file.
How can I get statistics on the huge pages?
I wrote this simple bash script which can be used, having the name of the process, to know if that process is using or not the huge pages.