Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Apr 2005 11:37:55 +0200
From:      cpghost@cordula.ws
To:        Dick Hoogendijk <dick@nagual.st>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: HZ=1000 ?
Message-ID:  <20050404093755.GA48928@epia2.farid-hajji.net>
In-Reply-To: <20050404091719.GA9748@lothlorien.nagual.st>
References:  <20050404091719.GA9748@lothlorien.nagual.st>

next in thread | previous in thread | raw e-mail | index | archive | help
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
either.

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

-cpghost.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050404093755.GA48928>