By Fat Bloke on Jan 04, 2010
With the clock ticking over to a new decade, now would seem to be a good time for a quick blog on timer interrupts in guests and how you can speed up your guests, while also lightening the load on your host, with the judicious use of a bit of guest configuration.
All operating systems make use of a system clock which ticks at a particular frequency. Common Linux distributions use kernels which drive the clock at 100Hz, 250Hz or 1000Hz. You can find out what your Linux kernel is configured for using this command:
grep CONFIG_HZ /boot/config-<kernel>
where kernel is the version of Linux you're running. The result of this command on my Oracle Enterprise Linux installation looks like this:
[root@localhost grub]# grep CONFIG_HZ /boot/config-2.6.18-164.el5 # CONFIG_HZ_100 is not set # CONFIG_HZ_250 is not set CONFIG_HZ_1000=y CONFIG_HZ=1000
...which tells me that my kernel is configured to use a 1000Hz clock tick.
In a virtualized environment this means that there will be lots of context switches as the host schedules the guest to deal with clock ticks which don't do very much. And this will become most visible by seeing a relatively high host cpu usage even when the guest is idle. (Note that the exact behaviour also depends on the host system. For example, the same OEL vm runs comfortably on my Mac host, but my Windows host gets very busy running it.)
If you see an idle Linux guest which is configured for a 1000Hz clock using up lots of host cpu cycles, you may want to reduce the clock frequency using the boot time parameter "divider=10". You can do this by adding the parameter manually as the grub boot loader starts, or by editing the grub configuration file as follows:
- Edit /boot/grub/grub.conf
- Duplicate the existing Title section, and rename it (this means you can choose at boot time which config to use)
- Add the "divider=10" parameter as follows:
kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/VolGroup01/LogVol00 rhgb quiet divider=10
This results in fewer context switches, a lighter host load (as measured by Window Task Manager) and faster guest execution. For example, the speed to boot my OEL vm (on a Windows 7 host) dropped from 115 seconds to 80 seconds which, according to my calculations, is a 30% increase in performance. Not bad for a simple bit of configuration