Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Aug 2003 13:54:10 -0700
From:      "Sean Hamilton" <sh@bel.bc.ca>
To:        <hackers@freebsd.org>
Subject:   Tuning HZ for semi-realtime applications
Message-ID:  <000501c35a01$6383e040$0300000a@antalus>

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000501c35a01$6383e040$0300000a>