JVM 需要很长时间才能解析 localhost 的 ip-address [英] Jvm takes a long time to resolve ip-address for localhost

查看:24
本文介绍了JVM 需要很长时间才能解析 localhost 的 ip-address的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在升级到 macOS Sierra 后,我似乎遇到了sbt 测试"(包括查找本地主机名称/IP 地址)的性能问题.在以前版本的 OS X 上,大约需要 40-50 秒才能完成.macOS Sierra 时间远高于此.我最后一次跑了大约 15 分钟.编译时间与El Capitan"大致相同.

我是团队中唯一尝试过这款新 macOS 的人,所以我不知道它是只发生在我的 Mac 上还是普遍存在的问题.

我的同事在 Ubuntu 上遇到了类似的问题,这与随机数生成减慢测试有关 - 缓慢的服务响应时间:Java SecureRandom &/dev/随机

不幸的是,这对我不起作用.最初我在 JDK 8u54 上尝试过,然后尝试更新到 JDK 8u102,但也没有帮助.

附言我正在运行 Macbook Pro 2015 年年中 2.8GHz i7、16GB 内存、1TB SSD.

解决方案

我遇到了同样的问题.升级后,Tomcat 从 15 秒到 6 分钟初始化 spring 上下文……禁用 csrutils 并没有解决我的问题.

解决了问题,方法是在映射到code>127.0.0.1 地址以及 ::1 像这样:

127.0.0.1 本地主机 mbpro.local::1 本地主机 mbpro.local

如果您有兴趣,可以在此处找到有关问题和解决方案的一些详细信息:https://thoeni.io/post/macos-sierra-java/>

在帖子中,我还链接到 github 项目,以帮助解决问题并验证解决方案.

问题与(我相信)本地主机名称解析的工作方式以及 java.net.InetAddr 类如何检索地址有关.我与少数同事进行了验证,显然升级到 Sierra 的每个人都不会发生这种情况,但我仍在调查这种变化的根源.

无论如何,解决方案与 antid0te 立即实施并起作用一样.

I seem to have a problem with performance of "sbt test" (which includes looking up localhost names/IP addresses) after upgrading to macOS Sierra. On a previous version of OS X it took about 40-50 seconds to finish. macOS Sierra times are much higher than that. Last run I did was around 15 minutes. Compile times are about the same as on 'El Capitan'.

I'm the only one from my team to try this new macOS so I can't tell if it's only happening on my mac or is it a universal issue.

My colleague had a similar issue on Ubuntu and it was related with random number generation slowing down the tests - Slow service response Times : Java SecureRandom & /dev/random

Unfortunately, that didn't work for me. Originally I tried that on JDK 8u54 and then tried updating to JDK 8u102 and that didn't help as well.

P.S. I'm running Macbook Pro Mid-2015 2.8GHz i7, 16GB ram, 1TB SSD.

解决方案

I had the same problem. Tomcat went from 15 seconds to 6 minutes to initialise spring context after the upgrade... disabling csrutils didn't solve the issue for me.

I solved the problem by adding my Mac hostname (i.e. Macbook.local, or whatever your Mac is called) on the /etc/hosts file mapped to the 127.0.0.1 address as well as the ::1 like this:

127.0.0.1   localhost mbpro.local
::1         localhost mbpro.local

If you're interested you can find some details on the issue and solution here: https://thoeni.io/post/macos-sierra-java/

On the post I also link to a github project to help troubleshooting the issue and validating the solution.

The problem is related (I believe) on how the localhost name resolution works and how the java.net.InetAddr class is retrieving the addresses. I verified with few colleagues and apparently it doesn't happen to everyone who upgraded to Sierra, but I'm still investigating the roots of this change.

The solution anyway was the same that antid0te implemented and worked immediately.

这篇关于JVM 需要很长时间才能解析 localhost 的 ip-address的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆