Thread.sleep is very incorrect on kern.hz FreeBSD-10 + openjdk8.
Sergey Potapov
sp at smartspb.net
Thu Nov 12 16:18:25 UTC 2015
Hello!
FreeBSD-10.1 without tunning.
openjdk8 without tunning (pkg install).
Thread.sleep depends on kern.hz sysctl variable.
Simple program and more detailed version information attched.
openjdk7 tested with kern.hz=2000 -- same results.
kern.hz: 100
1000 times Thread.sleep(1) 19994 milliseconds
1000 times Thread.sleep(2) 19997 milliseconds
1000 times TimeUnit.MICROSECONDS.sleep(100) 20000 milliseconds
kern.hz: 1000
1000 times Thread.sleep(1) 2002 milliseconds
1000 times Thread.sleep(2) 3000 milliseconds
1000 times TimeUnit.MICROSECONDS.sleep(100) 2001 milliseconds
kern.hz: 2000
1000 times Thread.sleep(1) 1500 milliseconds
1000 times Thread.sleep(2) 2500 milliseconds
1000 times TimeUnit.MICROSECONDS.sleep(100) 1500 milliseconds
Linux and Windows are much better (but don't support anything less 1ms too).
Linux:
sysctl: cannot stat /proc/sys/kern/hz: No such file or directory.
1000 times Thread.sleep(1) 1077 milliseconds
1000 times Thread.sleep(2) 2078 milliseconds
1000 times TimeUnit.MICROSECONDS.sleep(100) 1079 milliseconds
Windows (with sysctl command removed):
1000 times Thread.sleep(1) 1002 milliseconds
1000 times Thread.sleep(2) 2000 milliseconds
1000 times TimeUnit.MICROSECONDS.sleep(100) 1002 milliseconds
--
Sergey Potapov.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: javaSleep.tgz
Type: application/octet-stream
Size: 5532 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-java/attachments/20151112/be5df50a/attachment.obj>
More information about the freebsd-java
mailing list