kern.hz - what is it and why is it needed on a VM?

On some of my old guest VM running on VMware Fusion (Mac), /boot/loader.conf contains:

Code:
kern.hz=100

But now I'm installing a couple of new virtual machines on a new ESXi box and need to know if I still need to set it on these new guests.

  1. What is kern.hz exactly?
  2. Why does it need to be set on a VM?
  3. Some people use
    Code:
    kern.hz=100
    and some use
    Code:
    kern.hz=50
    What's the difference?
  4. What is the default value, when not specifying it explicitly?
  5. Is this still necessary today for a FreeBSD 9.2 guest running on an ESXi 5.5 host?

Thanks
 
I believe it's related to the kernel API described in timeout(9) and it seems it's some sort of framework for periodic callbacks to user (not userspace user but a device driver for example) provided functions. The sysctl(8) seems to set the resulution, number of ticks per second in other words, of the timer used for the callbacks. The default value on my systems (stable/10 i386) seems to be 1000. I wouldn't change it unless there's a very good reason to do so.
 
One of the reasons it's recommended to set
Code:
kern.hz=100
on a virtual machine is to reduce the impact of 'time drift' caused by the unreliable allocation of resources by any hypervisor. I'm not sure how relevant this is now, and if you're using ntp once an hour or your hypervisor's guest tools for keeping time in sync, I'd expect this tweak to have little impact.
 
I remember reading that there is ongoing work to get rid of kern.hz alltogether and the timeout(9) framework is being modified not to depend on a user settable timer.
 
My FreeBSD VMs (OS X and FreeBSD VirtualBox hosts) are using 3-4% of the CPU at idle without that parameter.
 
My VM (FreeBSD 9.2 on ESXi 5.5) is only using 0.5-1.0 % CPU when idle without the parameter, and I don't have any time synchronization issues that I'm aware of - so I think I'm going to go with the default setting (i.e. not setting it at all).
 
Back
Top