Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Aug 2003 00:33:47 -0400
From:      Chris BeHanna <chris@behanna.org>
To:        hackers@freebsd.org
Subject:   Re: Tuning HZ for semi-realtime applications
Message-ID:  <200308060033.47237.chris@behanna.org>
In-Reply-To: <000501c35a01$6383e040$0300000a@antalus>
References:  <000501c35a01$6383e040$0300000a@antalus>

next in thread | previous in thread | raw e-mail | index | archive | help
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@bogus.behanna.org
                 Turning coffee into software since 1990.



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