Skip to content

Conversation

rdesgroppes
Copy link

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 ReparsePoints,
  • batching files passed to buildifier reduces process creation overhead, with a limit to account for Windows command line length limitations.

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.
rdesgroppes added a commit to DataDog/datadog-agent that referenced this pull request Oct 16, 2025
### What does this PR do?
Apply a last path on `buildifier`'s runner script template on Windows:
- bazelbuild/buildtools#1404

### Motivation
Decrease execution time from [~2
minutes](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1177131952#L77)
to [~2
seconds](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1180039154#L99).

### Describe how you validated your changes
Locally (Windows VM) and in CI
(1985f7f).

### Additional Notes
Closes [ABLD-174](https://datadoghq.atlassian.net/browse/ABLD-174).

[ABLD-174]:
https://datadoghq.atlassian.net/browse/ABLD-174?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant