Skip to content

Allow sharing caches across actions when sandboxing is in use #7527

Open

Description

@ktf

Description of the problem / feature request:

Extremely low performance of bazel when building a large project on macOS when compared to running CMake + make.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Build a large bazel project on macOS. I see that a lot of fsevents for files in /private/var/tmp/_bazel_user triggered and fseventsd seems to crawl at 100% - 200% CPU usage after them, slowing down the builds. I do have /private/var/tmp masked out in my spotlight configuration, but it does not seem to be enough.

What operating system are you running Bazel on?

Darwin grisu.dyndns.cern.ch 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64

What's the output of bazel info release?

release 0.22.0

Activity

  1. irengrig commented on Mar 1, 2019

    @irengrig
    Contributor

    Hello @ktf, thank you for your feedback.
    Do you some particular project in mind that we can experiment with?

  2. ktf commented on Mar 2, 2019

    @ktf
    Author

    What I have is:

    https://github.com/ktf/AliceO2/tree/bazel-support

    where you can for example do bazel build @root//:cling. Given this is a subset of tensorflow (i.e. the part which builds llvm), plus some extra stuff to build parts of clang, I am surprised this is not a common issue. Notice I build on my local laptop (2015 MBP) with no external cache.

  3. added
    z-team-Apple
    untriaged
    and removed on Mar 2, 2019
  4. irengrig commented on Mar 2, 2019

    @irengrig
    Contributor

    Thank you for the example project!
    Assigning to Apple team.

  5. keith commented on Mar 2, 2019

    @keith
    Member

    It might be worth trying to repro with this commit 0877340

  6. jmmv commented on Mar 2, 2019

    @jmmv
    Contributor

    Indeed; that commit may help and I'd be very interested to know if it does.

    But I have also noticed fseventsd consuming lots of CPU (and, incidentally, this service runs at default priority -- so that commit actually makes Bazel run at a lower priority which is probably good). Haven't had a chance to dig into this. Maybe setting --nowatchfs would prevent the fseventsd activity, though then Bazel will be slower to detect file changes of course... (just thinking aloud). It just feels stupid that we have to waste so much CPU just to watch for file changes...

  7. added
    P2
    and removed
    untriaged
    on Mar 2, 2019
  8. self-assigned this
    on Mar 2, 2019
  9. ktf commented on Mar 3, 2019

    @ktf
    Author

    Thanks. I will try that when I have a bit of time. Notice also that the fsevents seem to be relative to stuff in /var/tmp/_bazel_user/, not in ~/src/myproject. Maybe I simply do not understand the bazel internals, but is that what you'd expect from the file watching process?

  10. jmmv commented on Mar 3, 2019

    @jmmv
    Contributor

    Yes. That's where the build artifacts are -- they are not stored in your source tree -- and Bazel has to watch them for out-of-band changes.

  11. 33 remaining items

  12. added
    team-Local-Exec
    on May 14, 2020
  13. added
    stale
    on Feb 16, 2023
  14. sgowroji commented on Feb 16, 2023

    @sgowroji
    Member

    Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

  15. brentleyjones commented on Feb 16, 2023

    @brentleyjones
    Contributor

    This is still relevant.

  16. added
    not stale
    and removed
    stale
    on Feb 16, 2023
  17. Kila2 commented on Jun 24, 2024

    @Kila2

    I found that when exec bazel builds. macos is listening to the bazel workspace and bazel-out directory. I don't think the bazel-out directory should be included here.
    ps: the watchfs option is false

  18. ktf commented on Sep 5, 2024

    @ktf
    Author

    Any update on this?

  19. Kila2 commented on Sep 5, 2024

    @Kila2

    We found a workaround: use a ramdisk or hdiutil to create a new tmp volume. Then, disable fseventsd for this volume to keep the CPU usage of the fseventsd process lower.

  20. nickdesaulniers commented on Nov 6, 2025

    @nickdesaulniers

    This would be nice to have. Is the assignee for this issue stale?

  21. nickdesaulniers commented on Nov 6, 2025

    @nickdesaulniers

    The Clang and Swift implicit module caches are inherently incompatible with hermetic builds and sandboxed execution. The only way to achieve the same degree of performance as the implicit module cache in a Bazel-like build is to explicitly precompile the modules as part of the build graph and propagate them as known inputs/outputs instead of dumping them into a single common directory.

    @allevato do you have an example of this?

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

Metadata

Metadata

Assignees

Labels

P2not staleteam-Local-Exectype: feature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions