Tuning HZ for semi-realtime applications

Chris BeHanna chris at behanna.org
Tue Aug 5 21:33:55 PDT 2003


On Sunday 03 August 2003 16:54, Sean Hamilton wrote:
> Greetings,
>
> [...wants to send out a lot of traffic, then read responses 1000
> times per second...is currently using select(2) in a loop...]
>
> Should I set HZ to 1000 (the frequency of my application) or should I set
> it to a much higher value? The CPU is running at around 2 GHz, and I set it
> as high as 50,000 with no problems. However, the granularity of my timeout
> appears to be restricted to 1/1000th of a second.

    harti@ already answered this.  I have no experience playing with
HZ settings, but his response sounds reasonable enough.

> I would like to use poll(2) instead of select, but it appears to take its
> timeout parameter in milliseconds, which aren't precise enough to keep my
> timing reasonable, especially if I ever need to increase my frequency.
>
> Another option would be calling poll/select with no timeout, in a loop.
> However, this seems like a waste of CPU time.

    You could insert an appropriately-sized nanosleep(2) into such a
loop.

-- 
Chris BeHanna
Software Engineer                   (Remove "bogus" before responding.)
chris at bogus.behanna.org
                 Turning coffee into software since 1990.



More information about the freebsd-hackers mailing list