Quick Tip: Fix extreme laggy virtual machines under Linux host

Apr 4, 2022

Recently my virtual machine setup under a Linux host (Kernel 5.13.0) has been plagued by extreme lagginess to the point of being unusable. Checking top shows that vmware-vmx is using all the CPU that is allocated to the VM, but the VM does not respond.

Things I tried that didn’t work:

  • Disable 3D acceleration
  • Launching VMWare player with the NVIDIA GPU (Intel iGPUs are blacklisted from hardware acceleration)
  • Disable visual effects in the Windows guest

Something in top stood out to me and it was kcompact. A Google search reveals that VMware fights with the Linux kernel memory compression, which is why it deadlocks every 30 seconds then keep fighting. The solution is simple:

sudo sysctl vm.compaction_proactiveness=0

Or vm.compaction_proactiveness=0 can be set in sysctl.conf to be permanent.

Phew, now I can keep writing my draft again!

This is a quick tip post. They are written in a way to help users quickly resolve a problem that I ran into in my daily work and usually don’t go in depth about the details of ‘why’. Please feel free to comment or contribute to the knowledge.