Difference between revisions of "Performance Optimization"
Windows7ge (talk | contribs) |
Windows7ge (talk | contribs) |
||
Line 58: | Line 58: | ||
To make the VM use Hugepages enter the VM's .XML file and add <code><memoryBacking><hugepages/></memoryBacking></code> to the memory section: | To make the VM use Hugepages enter the VM's .XML file and add <code><memoryBacking><hugepages/></memoryBacking></code> to the memory section: | ||
<syntaxhighlight lang=text> | <syntaxhighlight lang=text> | ||
− | . . . | + | ... |
<memory unit='KiB'>16777216</memory> | <memory unit='KiB'>16777216</memory> | ||
<currentMemory unit='KiB'>16777216</currentMemory> | <currentMemory unit='KiB'>16777216</currentMemory> | ||
Line 64: | Line 64: | ||
<hugepages/> | <hugepages/> | ||
</memoryBacking> | </memoryBacking> | ||
− | . . . | + | ... |
</syntaxhighlight> | </syntaxhighlight> | ||
Hugepages are now enabled. | Hugepages are now enabled. |
Revision as of 03:38, 1 March 2020
After the initial creation of your Virtual Machine there are a number of performance tweaks you can make to your Guest's .XML file and/or the Host system to greatly increase the Guest's performance.
hugepages
Hugepages are a function that lets the system kernel use larger pages when reading or writing information to memory (RAM). When this is enabled and the Guest is configured to use them the performance can be greatly increased. How to enable Hugepages depends on your GNU/Linux distribution.
Note: When hugepages are configured this portion of memory is taken away from the Host. This means the Host will no longer be able to use it. Keep this in mind.
Debain (Ubuntu/Mint/Lubuntu/PopOS/etc)
First check if Linux isn't already using Hugepages with: cat /proc/meminfo | grep Huge
.
If the output resembles the following:
AnonHugePages: 2048 kB
ShmemHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
then Hugepages aren't enabled.
To enable Hugepages first check /etc/sysctl.conf
for the following entries:
vm.nr_hugepages=
vm.hugetlb_shm_group=
If they don't exist they can be appended to the end of the file.
The general rule of thumb is 1 Hugepage for every 2MB of of RAM to be assigned to the VM:
vm.nr_hugepages=8192
vm.hugetlb_shm_group=48
The above example will set aside approx 16GB. After saving the changes reboot the system.
Now to verify the changes rerun: cat /proc/meminfo | grep Huge
The output should resemble the following:
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 8192
HugePages_Free: 8192
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 16777216 kB
Hugepages are now enabled.
It's also recommended by RedHat to disable the old transparent hugepages. This can be done with:
echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled
Now restart the computer.
To make the VM use Hugepages enter the VM's .XML file and add <memoryBacking><hugepages/></memoryBacking>
to the memory section:
...
<memory unit='KiB'>16777216</memory>
<currentMemory unit='KiB'>16777216</currentMemory>
<memoryBacking>
<hugepages/>
</memoryBacking>
...
Hugepages are now enabled.