buildifier: improve Windows runner performance (#1404)

* buildifier: improve Windows runner performance

This change aims to improve the `buildidier`'s runner performance on
Windows where it can sometimes take minutes to complete.

It consists in replacing the slow COM `Scripting.FileSystemObject` with
a "native" PowerShell `Get-ChildItem -Recurse` for file discovery, and
batch `buildifier` invocations (100 files at a time) instead of invoking
once per file.

This improves performance on large codebases (like from about 2 minutes
to less than 3 seconds).

Notes:
- cross-process COM calls add latency, whereas `Get-ChildItem` is a
  compiled "cmdlet".
- by default, `Get-ChildItem` doesn't recurse into symbolic links to
  directories, which is consistent with the current implementation that
  explicitly avoids entering `ReparsePoint`s,
- batching files passed to `buildifier` reduces process creation
  overhead, with a limit to account for Windows command line length
  limitations.

References:
- https://stackoverflow.com/questions/73893997/comments-in-a-long-line-powershell-code-in-a-batch-script
- https://stackoverflow.com/questions/3205027/maximum-length-of-command-line-string
- https://devblogs.microsoft.com/oldnewthing/20031210-00/?p=41553
1 file changed
tree: 61673b8eb1d79e4472cae1eadbb761e2c8848176
  1. .bazelci/
  2. api_proto/
  3. build/
  4. build_proto/
  5. buildifier/
  6. buildozer/
  7. bzlenv/
  8. config/
  9. convertast/
  10. deps_proto/
  11. differ/
  12. edit/
  13. extra_actions_base_proto/
  14. file/
  15. generatetables/
  16. labels/
  17. lang/
  18. release/
  19. tables/
  20. testutils/
  21. unused_deps/
  22. warn/
  23. wspace/
  24. .bazelrc
  25. .bazelversion
  26. .gitignore
  27. .mailmap
  28. .pre-commit-config.yaml
  29. BUILD.bazel
  30. CODEOWNERS
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. go.mod
  34. go.sum
  35. launcher.js
  36. LICENSE
  37. MODULE.bazel
  38. README.md
  39. status.py
  40. update_generated.sh
  41. WARNINGS.md
  42. WORKSPACE
  43. WORKSPACE.bzlmod
README.md

Buildtools for bazel

This repository contains developer tools for working with Google's bazel buildtool.

Build status

Setup

See instructions in each tool's directory.