Tuning HZ for semi-realtime applications

Sean Hamilton sh at bel.bc.ca
Sun Aug 3 13:54:11 PDT 2003


Greetings,

I have an application which has some task it must execute at some interval
(approximately 1000 times per second.) This application calls select(2) in a
loop, and uses its timeout parameter to try to keep the timing consistent.

At the end of a cycle, it sends out a large amount of network traffic.
During the select loop, it expects to receive replies to all this traffic.

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.

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.

Also, as I am doing large amounts of network traffic, which NIC (preferably
gigabit) should I be using, to cause the least interference with my timing?

I do not require realtime performance. I am just looking to have this run as
smoothly as possible.

sh



More information about the freebsd-hackers mailing list