Improving Linux Disk I/O in Hyper-V

One of the complaints typically heard about Hyper-V is that Linux performance is just not there. Here is a tip you can use that will improve your Linux VM performance by 20% to 30%.

Linux kernel 2.6 and newer offer four different I/O elevators (four different algorithms to accommodate different workloads and provide optimal performance).

These elevators are:

  • Anticipatory: Ideal for an average PC with a single SATA drive. It anticipates I/O and writes in one large chunk to the disk as opposed to multiple smaller chunks. This was the default prior to kernel 2.6.18
  • CFQ (Complete Fair Queueing): Ideal for multi-user environments, as its implements a Quality of Service policy that creates a per-process I/O queue. This is the default as of kernel 2.6.18. It’s for heavy workloads with competing processes.
  • Deadline: A round robin-like elevator algorithm produces near real-time performance. It also eliminates the possibility of process starvation.
  • NOOP (No Operation): Its I/O processor overhead is very low and it is based on the FIFO (First In, First out) queue. NOOP pretty much assumes something else is taking care of the elevator algorithm (a hypervisor, for example).

Anticipatory, CFQ and Deadline are great algorithms, but in a virtual machine these are bottlenecks since the hypervisor is responsible for mapping the virtual to physical storage. It is highly recommended that you set the elevator algorithm to NOOP which is the leanest and simplest elevator for virtualized environments. It allows the hypervisor to assign the ideal elevator and that results in better performance for Linux VMs. The only requirement is that your Linux distribution must have kernel version at lease 2.6.

In order to change the default elevator alrogithm, open /etc/default/grub file in your favorite text editor and add ‘elevator=noop’ at the end of the line (but inside the double quotes).

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"

After you make the change, run ‘sudo update-grub2’

vim /etc/initramfs-tools/modules
# append lines:
update-initramfs -u
Enter your comment:
154 +0 =
  • linux/misc/improve_io_hyper-v.txt
  • Last modified: 2019/10/31 09:05
  • by