From owner-freebsd-hackers Wed Aug 8 7:40:14 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from iona.dcs.gla.ac.uk (iona.dcs.gla.ac.uk [130.209.240.35]) by hub.freebsd.org (Postfix) with ESMTP id 1054737B409 for ; Wed, 8 Aug 2001 07:40:05 -0700 (PDT) (envelope-from neugebar@dcs.gla.ac.uk) Received: from therese.dcs.gla.ac.uk ([130.209.241.134] helo=therese.dcs.gla.ac.uk.dcs.gla.ac.uk) by iona.dcs.gla.ac.uk with esmtp (Exim 3.13 #1) id 15UUV8-00053B-00; Wed, 08 Aug 2001 15:40:02 +0100 Received: by therese.dcs.gla.ac.uk.dcs.gla.ac.uk (8.11.3/Dumb) id f78EdtE30541; Wed, 8 Aug 2001 15:39:55 +0100 (BST) To: "Weiguang SHI" Cc: bright@mu.org, jeff@expertcity.com, freebsd-hackers@freebsd.org Subject: Re: timing question References: From: Rolf Neugebauer Date: 08 Aug 2001 15:39:54 +0100 In-Reply-To: "Weiguang SHI"'s message of "Tue, 07 Aug 2001 10:11:11 -0600" Message-ID: Lines: 46 User-Agent: Gnus/5.0805 (Gnus v5.8.5) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "Weiguang SHI" writes: > >From: Alfred Perlstein > >To: Jeff Behl > >CC: "'freebsd-hackers@freebsd.org'" > >Subject: Re: timing question > >Date: Mon, 6 Aug 2001 14:49:55 -0500 > > > >* Jeff Behl [010806 12:48] wrote: > > > please excuse and direct me to the right place if this isn't the > > appropriate > > > place to post this sort of question.... > > > > > > we're looking into moving to freebsd (yea!), but found the following > > > problem. It seems that the shortest amount of time the below code will > > > sleep for is 20 seconds! any call to nanosleep for 5,10, etc miliseconds > > > returns a 20 ms delay. are we doing something wrong? > > > >You may have to increase the kernel value for HZ so that you get > >more fine grained clock interrupts. > > I didn't look at the code but if increasing the value of 'hz' will > result in more clock-interrupts/sec thus more overhead, wouldn't it be > better to auto-adjust the clock-interrupt rate somewhere in the OS > to clock-interrupt at big strides in the beginning but at > finer-grained interval as the actual timeout event approaches? The overhead for increasing the hz value to say 1000 is not too severe. I used the simple benchmark from the Loadable Scheduler Modules for Linux project [1] to measure the scheduling overhead on a 4.3-stable box. Increasing hz from 100 to 1000 incurs an overhead of .4 % on a PIII 450MHz. NB. for achieving higher timer resolutions you might find it interesting to look at Soft-Timers at Rice [2]. Events are scheduled at the usual timer interrupt frequency but the time wheels are also checked at system-call and other interrupt times, thus, depending on load, achieving finer grained timer resolutions. The TOCS paper, referenced on that site, also describes a mixed approach between Soft-Timers and hardware timers to achieve tighter delay bounds. Rolf [1] http://resourcemanagement.unixsolutions.hp.com/WaRM/docs/loadable_sched.html#Performance Measurement [2] http://www.cs.rice.edu/CS/Systems/Soft-timers/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message