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



## AlexSanchezSTHLM (Nov 23, 2013)

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


```
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.


 What is kern.hz exactly?
 Why does it need to be set on a VM? 
 Some people use 
	
	



```
kern.hz=100
```
 and some use 
	
	



```
kern.hz=50
```
 What's the difference?
 What is the _default_ value, when not specifying it explicitly?
 Is this still necessary _today_ for a FreeBSD 9.2 guest running on an ESXi 5.5 host?

Thanks


----------



## kpa (Nov 23, 2013)

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.


----------



## Savagedlight (Nov 23, 2013)

One of the reasons it's recommended to set 
	
	



```
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.


----------



## kpa (Nov 23, 2013)

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.


----------



## kpa (Nov 23, 2013)

I wonder if this information in the handbook is current anymore? It does instruct you to reduce kern.hz to 100 to " reduce the CPU utilization of FreeBSD under the..."

https://www.freebsd.org/doc/handbook/virtualization-guest.html


----------



## trh411 (Nov 24, 2013)

My FreeBSD VMs (OS X and FreeBSD VirtualBox hosts) are using 3-4% of the CPU at idle without that parameter.


----------



## AlexSanchezSTHLM (Nov 24, 2013)

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).


----------

