Knowledge Base

The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
 
Search the VMware Knowledge Base (KB)   View by Article ID
 

Virtual machine seems slow when running a particular program (Clock Issue) (892)

Details

Whenever I run a particular program inside a virtual machine, my virtual machine seems extremely slow. In particular, clocks and timers run very slowly. Is there a way to improve the performance of my virtual machine?

Solution

This issue can occur on a Linux host running 2.4 kernel when the virtual machine is running software that requires a high-speed timer, such as the Windows multimedia timer. The issue does not typically occur if the host is running a 2.6 kernel, because these kernels have a faster timer interrupt rate by default.

When the virtual machine requires a high-speed timer, the requirement is usually met by /dev/rtc on the host. In some circumstances, /dev/rtc is unavailable, leading to slowness in the guest.

The main symptom is that the virtual machine's clock fails to keep time properly. In addition, applications that are timed by the virtual machine's clock, such as Windows menu animations, may also run slowly. Applications that do not use the timer to delay their execution run at normal speed.

Note: Before deciding whether to attempt the workaround described below, be sure to read the Background section at the end of this article. It contains a more detailed description of the symptoms to help you decide whether the workaround applies to the problem you are seeing.

Workaround
 
The workaround has two parts: building a custom kernel for your Linux host so it uses a higher timer interrupt rate, and adding a special setting to the virtual machine's configuration file:
  1. Build a custom kernel. See the documentation for your Linux distribution for detailed instructions on how to build and run a custom kernel.

    There is one key change you must make before building the custom kernel.

    Locate the following line in /usr/src/linux-2.4/include/asm-i386/param.h:

    #define HZ 100
    

    Change the value of HZ to 1000:

    #define HZ 1000
    

    Note: For certain Red Hat Linux 7 and 8 kernels — including 2.4.18-18.7.x and some later versions — the procedure for increasing the timer interrupt rate is different. Do not edit the value of HZ in /usr/src/linux-2.4/include/asm-i386/param.h. Instead, configure a new kernel in the normal way (use either make config or make xconfig) and change the value of CONFIG_HZ to 1024. If you use make xconfig, you can find the option in the General setup menu. Then proceed to compile the kernel according to the Red Hat instructions.

    Note: The driver in /usr/src/linux-2.4/drivers/net/sk98lin (the driver for the GEnesis PCI Gigabit Ethernet Adapter) does not compile with HZ set to anything other than 100. Unless you need this driver, simply omit it when configuring the kernel. If you do need this driver, see the section Patch for sk98lin below.

  2. Edit the virtual machine's configuration file.

    Open the configuration (.vmx or .cfg) file for the virtual machine in a text editor and add the following line:

    host.useFastclock = FALSE
    

    Reboot the host using your custom kernel and launch the virtual machine; it should run the application that requires a high-speed timer without causing the virtual machine to run slowly.

Patch for sk98lin

If you need to use the driver in /usr/src/linux-2.4/drivers/net/sk98lin, you can try the following patch for sk98lin. Note that this patch is untested.

--- ../linux-2.4.18-10/drivers/net/sk98lin/h/skgepnm2.h Wed Jul  4
11:50:39 2001+++
./drivers/net/sk98lin/h/skgepnm2.h  Wed Oct  2 18:44:17 2002
@@ -341,7 +341,12 @@
#if SK_TICKS_PER_SEC == 100
#define SK_PNMI_HUNDREDS_SEC(t)        (t)
#else
+/* x86 kernel runtime doesn't support 64-bit
multiplication/division */
+#define SK_PNMI_HUNDREDS_SEC(t)        +  (((unsigned long)(t)) / ((unsigned long)SK_TICKS_PER_SEC/100))
+/***
#define SK_PNMI_HUNDREDS_SEC(t)        (((t) * 100) /
(SK_TICKS_PER_SEC))
+***/
#endif

Background

This issue occurs when guest operating systems or applications running in the virtual machine request a virtual timer interrupt rate that is higher than the real timer interrupt rate the host operating system is using.

In older VMware products (prior to VMware Workstation 4.5 and GSX Server 3), this issue occurs whenever you run more than one virtual machine that requires a high-speed timer. In these products, check the Devices menu to see whether /dev/rtc is available and connected. If only one virtual machine has /dev/rtc connected, it runs properly. If more than one virtual machine needs /dev/rtc at the same time, you may see this issue.

You may also see this issue, even in current products, if a non-VMware application on the host is using /dev/rtc or if your host Linux kernel does not have full support for /dev/rtc. In particular, you are likely to see this issue if your host is a 64bit system running Red Hat Enterprise Linux 3. The 64bit version of this distribution uses a Linux 2.4 kernel whose /dev/rtc driver cannot generate interrupts, and it runs its main system timer at 100Hz.

Most Linux kernels 2.4 and earlier also use 100Hz, but have full support for /dev/rtc.

Note: If you are running a 2.6 kernel on your Linux host, this article does not apply. The default timer interrupt rate for a 2.6 kernel is already 1000Hz, so /dev/rtc is usually not needed.

This issue commonly occurs with the following software in the virtual machine:

  • Any Windows guest operating system with a running application that uses the multimedia timer to increase the virtual timer interrupt rate.
  • Windows 98, which uses a virtual timer interrupt rate of 200Hz even when the multimedia timers are not in use.
  • Red Hat Linux 7 and 8 with certain kernel versions, including 2.4.18-18.7.x and some later versions, which use a virtual timer interrupt rate of 512Hz.
  • Linux kernel version 2.6, which uses a virtual timer interrupt rate of 1000Hz. If you do not need the higher interrupt rate, you can recompile the guest operating system to use a 100Hz rate. For more information, see Determining and changing the rate of timer interrupts a guest operating system requests (1005802).
  • SUSE LINUX 9.0 as a guest operating system, which includes a 2.4 kernel that has been modified to use a virtual timer interrupt rate of 1000Hz if the desktop kernel command line option is given. You can remove this option to change the rate back to 100Hz. For more information, see Determining and changing the rate of timer interrupts a guest operating system requests (1005802)

You should set the host HZ value to the fastest guest value. The recommended value of 1000 should cover all these cases.

There are some drawbacks to increasing the value for HZ. In particular, running top on the host gives misleading results, because top assumes HZ is always 100.

Keywords

892; urlz

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 30 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (4000 or fewer characters)
  • 30 Ratings
Actions
KB: