bazel: Mac OS X: builds hang for 10-20 seconds due to localhost name resolution

Running a clean build on Mac OS X Sierra hangs for 10-20 seconds before actually executing. Running jstack shows that it is stuck in NetUtil.findShortHostName, trying to resolve the localhost name. The following blog post shows that this is a common issue, and suggests adding entries to /etc/hosts which fixes the problem. I suggest that possibly the result of this lookup should be cached by the blaze server?

Detailed description of this issue: https://thoeni.io/post/macos-sierra-java/

Bazel logs showing 20 seconds to do nothing

Bazel pauses for ~20 seconds before printing anything:

$ ~/bazel/bin/bazel build //prpcpython:test_prpc
INFO: Found 1 target...
Target //prpcpython:test_prpc up-to-date:
  bazel-bin/prpcpython/test_prpc
INFO: Elapsed time: 20.563s, Critical Path: 0.00s

The java.log showing the 20 second pause:

170818 13:54:31.431:I 1711 [com.google.devtools.build.lib.skyframe.LegacyLoadingPhaseRunner.execute] Target pattern evaluation finished
170818 13:54:31.431:I 1711 [com.google.devtools.build.lib.runtime.CacheFileDigestsModule.logStats] Accumulated cache stats before command: hit count=5, miss count=365, hit rate=0.013513513513513514, eviction count=0
170818 13:54:51.515:I 1711 [com.google.devtools.build.lib.buildtool.BuildTool.buildTargets] Configurations created
170818 13:54:51.516:I 1711 [com.google.devtools.build.lib.analysis.BuildView.update] Starting analysis

How to reproduce

Unfortunately, I’m not entirely sure exactly what configuration triggers this problem since my co-worker has the same OS version and doesn’t run into this. However for me the following things reproduce this issue:

  1. Run a clean build of a single target, observe the elapsed time is always > 10 seconds.
  2. Run ping computername.local and observe that it also takes > 10 seconds.
  3. Add an entry in /etc/hosts to add a name and observe that the problem goes away.
  4. Turn on any of the sharing services in the system control panel and observe that the issue goes away.

Environment info

  • Operating System: Mac OS X Sierra (10.12.6)
  • Bazel version (output of bazel info release): release 0.5.4rc3

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 17 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I think we should resolve the local hostname once on server startup and print a warning message if that takes longer than e.g. 5 seconds, to make sure that people don’t blame Bazel for what is essentially a local configuration or network issue. Then we should use that hostname consistently during server lifetime.

For anybody who have added entry to /etc/hosts but still see hanging, add ab ipv6 entry as well. like this 127.0.0.1 MacBook-Pro.local ::1 MacBook-Pro.local

It is not in the current rc so it will be in next month release. With our coming change to our release process it will be cut on 10/01 and release around the end or October (this is subject to change)

On Fri, Sep 15, 2017, 8:23 AM Sebastian Ärleryd notifications@github.com wrote:

Great to see this fixed! What release do think it’ll make it into?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel/issues/3586#issuecomment-329693031, or mute the thread https://github.com/notifications/unsubscribe-auth/ADjHf8FLTXZj5gnrF3JuGm_TRlM0VLsFks5sihfRgaJpZM4O7lY0 .