From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 5 21:33:55 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 324CB37B401 for ; Tue, 5 Aug 2003 21:33:55 -0700 (PDT) Received: from topperwein.pennasoft.com (user183.net446.oh.sprint-hsd.net [65.40.131.183]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1FF3943F75 for ; Tue, 5 Aug 2003 21:33:54 -0700 (PDT) (envelope-from behanna@topperwein.pennasoft.com) Received: from topperwein.pennasoft.com (localhost [127.0.0.1]) h764Xq9j086362 for ; Wed, 6 Aug 2003 00:33:52 -0400 (EDT) (envelope-from behanna@topperwein.pennasoft.com) Received: from localhost (localhost [[UNIX: localhost]]) by topperwein.pennasoft.com (8.12.9/8.12.9/Submit) id h764Xles086361 for hackers@freebsd.org; Wed, 6 Aug 2003 00:33:47 -0400 (EDT) From: Chris BeHanna Organization: Western Pennsylvania Pizza Disposal Unit To: hackers@freebsd.org Date: Wed, 6 Aug 2003 00:33:47 -0400 User-Agent: KMail/1.5.3 References: <000501c35a01$6383e040$0300000a@antalus> In-Reply-To: <000501c35a01$6383e040$0300000a@antalus> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200308060033.47237.chris@behanna.org> Subject: Re: Tuning HZ for semi-realtime applications X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: chris@behanna.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Aug 2003 04:33:55 -0000 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.