Thread.sleep is very incorrect on kern.hz FreeBSD-10 + openjdk8.
Achilleas Mantzios
achill at matrix.gatewaynet.com
Thu Nov 12 16:26:09 UTC 2015
On 12/11/2015 18:17, Sergey Potapov wrote:
> 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
>
How about using even larger values for kern.hz ?
> 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.
>
>
>
>
> _______________________________________________
> freebsd-java at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-java
> To unsubscribe, send any mail to "freebsd-java-unsubscribe at freebsd.org"
--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
More information about the freebsd-java
mailing list