If I run the following on OS X Sierra (JDK 8u111), it takes 5 seconds to run (as opposed to milliseconds on e.g. Linux):
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
public class BeanTest {
public static void main (String[] args) {
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
System.out.println(bean.getName());
}
}
This is causing a massive slowdown of a library that I use, whose newer versions call this bit of the management API. My first thought is that it's a DNS issue (the computer is on a local home NAT) but my attempt to resolve either my local hostname or my local IP address in the shell returns an (NXDOMAIN) answer instantly. Running dtruss on the Java process produced constant repetition of these lines for the duration of the 5 second lag:
782/0x36f5: psynch_cvwait(0x7FEE4170B968, 0x20100000300, 0x200) = -1 Err#316
782/0x36f5: gettimeofday(0x7000039B4938, 0x0, 0x0) = 0 0
What is going on here and what can I do to unblock this bottleneck?
I fix the problem by manually set HostName to LocalHostName, before this, HostName is not set:
$ scutil --set HostName $(scutil --get LocalHostName)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With