From owner-freebsd-hackers Wed Dec 4 3:31:58 2002 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 7377637B406 for ; Wed, 4 Dec 2002 03:31:55 -0800 (PST) Received: from pcwin002.win.tue.nl (pcwin002.win.tue.nl [131.155.71.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5C71C43EA9 for ; Wed, 4 Dec 2002 03:31:54 -0800 (PST) (envelope-from stijn@pcwin002.win.tue.nl) Received: from pcwin002.win.tue.nl (localhost [127.0.0.1]) by pcwin002.win.tue.nl (8.12.6/8.12.6) with ESMTP id gB4BVsmr000380; Wed, 4 Dec 2002 12:31:54 +0100 (CET) (envelope-from stijn@pcwin002.win.tue.nl) Received: (from stijn@localhost) by pcwin002.win.tue.nl (8.12.6/8.12.6/Submit) id gB4BVsUI000379; Wed, 4 Dec 2002 12:31:54 +0100 (CET) Date: Wed, 4 Dec 2002 12:31:54 +0100 From: Stijn Hoop To: Mike Silbersack Cc: freebsd-hackers@freebsd.org Subject: Re: [nephtes@openface.ca: [Xmame] Use of usleep() with -sleepidle] Message-ID: <20021204113154.GA205@pcwin002.win.tue.nl> References: <20021202151816.GJ83264@pcwin002.win.tue.nl> <20021202114019.R31106-100000@patrocles.silby.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4SFOXa2GPu3tIq4H" Content-Disposition: inline In-Reply-To: <20021202114019.R31106-100000@patrocles.silby.com> User-Agent: Mutt/1.4i X-Bright-Idea: Let's abolish HTML mail! 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 --4SFOXa2GPu3tIq4H Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 02, 2002 at 11:49:03AM -0600, Mike Silbersack wrote: > The time select() takes should be directly related to your system's hz > setting. The default for FreeBSD is 100, which means that the interrupt > timer will fire every 10ms. If you want to play with that, edit > /etc/sysctl.conf and set kern.hz=3D"1000", which should give you 1 ms > accuracy. With the mentioned change of /etc/sysctl.conf to /boot/loader.conf, I am indeed seeing much better times on this 'benchmark'. See attached log. Not only the _select_sleep method benefits from this. What are the reasons *not* to do this? > As to why Linux may appear "better"... I believe that Linux defaults to > hz=3D100, but that the default switched to hz=3D1000 sometime in the rece= nt > past. And why don't we do the same? (I suspect this is related to the question above :) > To answer your final question: Sleep accuracy doesn't matter to most > applications, but I'm sure counterexamples could be found. Such as emulators :) Thanks for the responses, --Stijn --=20 I really hate this damned machine I wish that they would sell it. It never does quite what I want But only what I tell it. --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sleep-bsd-1700-hz1000.log" Script started on Wed Dec 4 11:46:30 2002 Testing _select_sleep (x 1000), delay 3 Total time: 4004.915000 ms; unit time: 4.004915 ms; estimated overhead: 1.004915 ms Testing _usleep_sleep (x 1000), delay 3 Total time: 4006.116000 ms; unit time: 4.006116 ms; estimated overhead: 1.006116 ms Testing _nanosleep_sleep (x 1000), delay 3 Total time: 4007.124000 ms; unit time: 4.007124 ms; estimated overhead: 1.007124 ms Testing _select_sleep (x 1000), delay 8 Total time: 9003.380000 ms; unit time: 9.003380 ms; estimated overhead: 1.003380 ms Testing _usleep_sleep (x 1000), delay 8 Total time: 8998.329000 ms; unit time: 8.998329 ms; estimated overhead: 0.998329 ms Testing _nanosleep_sleep (x 1000), delay 8 Total time: 8998.352000 ms; unit time: 8.998352 ms; estimated overhead: 0.998352 ms Testing _select_sleep (x 1000), delay 13 Total time: 14010.526000 ms; unit time: 14.010526 ms; estimated overhead: 1.010526 ms Testing _usleep_sleep (x 1000), delay 13 Total time: 14011.579000 ms; unit time: 14.011579 ms; estimated overhead: 1.011579 ms Testing _nanosleep_sleep (x 1000), delay 13 Total time: 14011.588000 ms; unit time: 14.011588 ms; estimated overhead: 1.011588 ms Testing _select_sleep (x 1000), delay 18 Total time: 18999.703000 ms; unit time: 18.999703 ms; estimated overhead: 0.999703 ms Testing _usleep_sleep (x 1000), delay 18 Total time: 19000.703000 ms; unit time: 19.000703 ms; estimated overhead: 1.000703 ms Testing _nanosleep_sleep (x 1000), delay 18 Total time: 18998.785000 ms; unit time: 18.998785 ms; estimated overhead: 0.998785 ms Testing _select_sleep (x 1000), delay 23 Total time: 23997.911000 ms; unit time: 23.997911 ms; estimated overhead: 0.997911 ms Testing _usleep_sleep (x 1000), delay 23 Total time: 24007.931000 ms; unit time: 24.007931 ms; estimated overhead: 1.007931 ms Testing _nanosleep_sleep (x 1000), delay 23 Total time: 23998.212000 ms; unit time: 23.998212 ms; estimated overhead: 0.998212 ms Testing _select_sleep (x 1000), delay 28 Total time: 29074.207000 ms; unit time: 29.074207 ms; estimated overhead: 1.074207 ms Testing _usleep_sleep (x 1000), delay 28 Total time: 29000.175000 ms; unit time: 29.000175 ms; estimated overhead: 1.000175 ms Testing _nanosleep_sleep (x 1000), delay 28 Total time: 29001.373000 ms; unit time: 29.001373 ms; estimated overhead: 1.001373 ms Script done on Wed Dec 4 11:51:27 2002 --jRHKVT23PllUwdXP-- --4SFOXa2GPu3tIq4H Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE97eeqY3r/tLQmfWcRAgrXAKCgnB0P6SO7VPtsw3HAZSaq2IfO3gCfQaHL yv2Acrm6AKwxGboHU8iSrU4= =M6qt -----END PGP SIGNATURE----- --4SFOXa2GPu3tIq4H-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message