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="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=100, but that the default switched to hz=1000 sometime in the recent
> 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
--
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.
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE97eeqY3r/tLQmfWcRAgrXAKCgnB0P6SO7VPtsw3HAZSaq2IfO3gCfQaHL
yv2Acrm6AKwxGboHU8iSrU4=
=M6qt
-----END PGP SIGNATURE-----