HZ=1000 ?

cpghost at cordula.ws cpghost at cordula.ws
Mon Apr 4 02:37:04 PDT 2005

On Mon, Apr 04, 2005 at 11:17:19AM +0200, Dick Hoogendijk wrote:
> I read about polling and HZ=1000. The latter is not high enough for
> vmware3 (it complains..). I read 'man polling' and learn something about
> this, but I really want to know more about 'hz=1000'
> The GENERIC has hz=100 as I recall (fbsd-4.11). Can somebody explain I
> "human language" what happens if you raise this HZ? Is there a processor
> related issue here? What exectly happens if you have 'hz=1000' or is it
> maybe better to have 'hz=2000' ? I can't decide now because I don't
> understand what happens.. So, anybody?

This is the frequency of the heart beat. Superficially, every 1/HZ second,
a clock tick happens and the kernel is invoked. Then stuff like cleanup and
scheduling a new thread happens (this is not the only time when threads
get scheduled though).

HZ=100 is good enough for most purposes. If the kernel needs to poll
some data faster and more frequently, you can crank up HZ to 1000 or
even higher. A system with higher HZ is usually also more responsive,
but this comes at a price:

* The overhead is higher (you need more time to do internal housekeeping,
  and there's less time available for userland threads)
* Processor caches are flushed more frequently, resulting in slower
  RAM access.

A high value for HZ is also not a good idea for slow(er) hardware

Interestingly, HZ=100 has remained constant for decades (!), despite
CPUs getting faster all the time. This is an excellent value for most
typical usage patterns. Cranking it up should only be required for
special cases. Anyway, the HZ knob is there. Experiment with it until
you get optimal performance.

> dick -- http://nagual.st/ -- PGP/GnuPG key: F86289CE
> ++ Running FreeBSD 4.11 ++ FreeBSD 5.3
> + Nai tiruvantel ar vayuvantel i Valar tielyanna nu vilja


Cordula's Web. http://www.cordula.ws/

More information about the freebsd-questions mailing list