Skip to content

Extremely slow genrule on Windows due to LDAP #4013

Closed

Description

@j3parker

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):

untitled

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

  1. added
    P2
    on Nov 3, 2017
  2. dslomov commented on Dec 5, 2017

    @dslomov
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2platform: windowstype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions