Repository navigation
Description
This issue is partially an FYI: it may not be Bazel's thing to fix or to continue to investigate (I'm not 100% sure but it looks that way.) At least this will be something others could search for. Feel free to close it if that makes sense.
Description of the problem / feature request / question:
genrule rules are extremely slow in Windows with msys2. The root cause appears to be syncing LDAP info.
Visible in procmon and WPA. Example (incomplete):
If possible, provide a minimal example to reproduce the problem:
In a BUILD file:
genrule(
name = "first",
srcs = [],
outs = ["foo.txt"],
cmd = "echo hey > $@",
)
genrule(
name = "second",
srcs = ["foo.txt"],
outs = ["bar.txt"],
cmd = "cp $(location foo.txt) $@",
)
Building:
PS C:\src\bazelslow> bazel build //...
INFO: Found 2 targets...
INFO: Elapsed time: 81.158s, Critical Path: 79.84s
(This will almost surely vary for other folks.) Each step takes roughly the same time. 81 seconds is pretty slow.
Environment info
- Operating System: Windows
- Bazel version (output of
bazel info release): release 0.7.0
Have you found anything relevant by searching the web?
There are a multiple reports of slowness with msys/cygwin due to LDAP that can be found via searching. For example, msys2/MSYS2-packages#138 or https://stackoverflow.com/questions/28410852/startup-is-really-slow-for-all-cygwin-applications . A suggested fix that works for me is to comment out "db" in /etc/nsswitch.conf (C:\Program Files\Git\etc\nsswitch.conf) like so:
passwd: files # db
This completely fixed it for me (note: "db" for cygwin is documented here https://cygwin.com/cygwin-ug-net/ntsec.html .) Of course, the downside is that now msys won't be the same user, but for me that's ok (not for folks that use "git bash".)

Activity
dslomov commentedon Dec 5, 2017
Looks like the slowness is in bash, not in Bazel (we do not call anything from msys-2.0.dll)
The only action we can (and should) take is to allow you to write genrules that do not involve bash.