Quation about HZ kernel option

Matthew Dillon dillon at apollo.backplane.com
Thu Oct 4 12:08:04 PDT 2007


    The basic answer is that HZ is almost, but not quite irrelevant.

    If a process blocks another will immediately be scheduled.  More
    importantly, if an interrupt driven event (keyboard, tty, network,
    disk, etc) wakes a process up the scheduler has the ability to force
    an IMMEDIATE reschedule.   Nearly ALL process related events schedule
    the process from this sort of reschedule.  Generally speaking only
    cpu-bound processes will be hitting the schedular quantum on a regular
    basis.

    For network protocols HZ is the basis for the timeout subsystem which
    is only triggered when things actually time-out, which is fairly rare
    in a normally running system.

    Queue timers, select timeouts, and nanosleep are restricted by HZ in
    granularity, but in nearly all cases those calls are used with
    very large timeouts not really subject to the granularity of HZ.

    I think a higher HZ can be somewhat beneficial if you are running a 
    lot of processes which fall through the scheduler's cracks (both cpu
    and disk bound, usually), or if the scheduler is badly written, but
    otherwise a lower value will not have much of an effect.  I would not
    go under 100, though.  I personally believe that a default of 1000 is
    ridiculously high, especially on a SMP system.

						-Matt



More information about the freebsd-stable mailing list