Make sandbox symlink forest deletions asynchronous.

Each sandbox action runs within a symlink forest that exists in a separate
subtree because we use a unique identifier for those subtrees.  Therefore
it is unnecessary to delete those trees in the critical path.

Tree deletions can be very expensive, especially on macOS, so make them
asynchronous if --experimental_sandbox_async_tree_delete_idle_threads is
given.  When this flag is not zero, Bazel will schedule all deletions on
a separate low-priority thread while the build is running, and will then
use the requested number of threads once the build is done to quickly
catch up with an still-ongoing deletions.

For a large iOS build, this cuts down clean build times with sandboxed
enabled significantly.  Helps more on machines with more cores:

* On a Mac Pro 2013, the improvement is almost 20%:

  standalone:      mean 2746.33, median 2736.00, stddev 33.07
  sandboxed-async: mean 4394.67, median 4393.00, stddev 33.09
  sandboxed-sync:  mean 5284.33, median 5288.00, stddev 20.17

* On a MacBook Pro 2015, we see a more modest 10% improvement:

  standalone:      mean 3418.33, median 3422.00, stddev 7.41
  sandboxed-async: mean 5090.00, median 5086.00, stddev 40.92
  sandboxed-sync:  mean 5694.67, median 5700.00, stddev 37.75

Partially addresses https://github.com/bazelbuild/bazel/issues/7527.

RELNOTES: None.
PiperOrigin-RevId: 243805556
22 files changed
tree: 6a414aa159779570f92cd797d2dbe75c6de3d56e
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .gitattributes
  9. .gitignore
  10. AUTHORS
  11. BUILD
  12. CHANGELOG.md
  13. CODEOWNERS
  14. combine_distfiles.py
  15. combine_distfiles_to_tar.sh
  16. compile.sh
  17. CONTRIBUTING.md
  18. CONTRIBUTORS
  19. distdir.bzl
  20. ISSUE_TEMPLATE.md
  21. LICENSE
  22. README.md
  23. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel only rebuilds what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status

Bazel is released in ‘Beta’. See the product roadmap to learn about the path toward a stable 1.0 release.