Rate This Document
Findability
Accuracy
Completeness
Readability

Huge Page Memory Enablement and Configuration in Virtualization Scenarios

Symptom

Test scenario: MariaDB is deployed on the VM, and Sysbench is deployed on the remote stress server.

Use Sysbench to perform 1:1 mixed read and write operations on MariaDB. The test involves 8, 16, 32, 64, 128, 256 or 512 threads. Two 4C24G VMs are virtualized on the server. The virtualization platform is KVM. The two VMs are located on different chips and use different NICs. Sysbench is deployed on a remote server and directly connected to the two NICs on the server through network cables. The following figure shows the test connection:

Key Process and Cause Analysis

The VM is a process on the host OS. The 4C24G specification indicates that 24 GB memory is required for running the VM process. Using huge page memory can reduce memory pages and manage virtual addresses, reduce memory page swap-in and swap-out, and improve the overall memory performance. Huge page memory is also enabled in NFV commercial scenarios.

Conclusion and Solution

VMs require a large amount of memory. Enabling huge page memory can improve the TLB hit ratio and system performance.

  1. Check the huge page memory used by the OS.
    cat /proc/meminfo |grep Huge
  2. Add the following configuration to the VM XML file to enable huge page memory:
      <memoryBacking>
        <hugepages/>
      </memoryBacking>
    <numatune>
        <memory mode='strict' nodeset='2'/>
      </numatune>

    nodeset='2' indicates that the memory of NUMA node 2 is used.

  3. Configure huge page memory in the Host OS.
    echo 56 > /sys/devices/system/node/node2/hugepages/hugepages-524288kB/nr_hugepages

    56 indicates the number of huge pages. Ensure that the number of huge pages multiplied by 512 MB is greater than the VM memory, so that the VM can be started.