Repository navigation
Conversation
`f not in ctx.files.excludes` scans the list of excluded files for every source file, so analyzing a `pkg_files` target takes time proportional to the product of the number of sources and excludes. Bazel's own `//:dist-srcs` has 14,411 sources and 8,807 excludes, which amounts to about 127M `File` comparisons on a single thread at the end of analysis. Checking against a dict instead reduces the cold analysis wall time of `bazel build --nobuild //src/...` in the Bazel repo from 14.40s to 13.92s on average (n=6, `--lockfile_mode=off`).
fmeum
marked this pull request as ready for review
October 17, 2026 19:12
Contributor
Author
|
FYI @meisterT |
Contributor
Author
|
Could you cut a release with the fix? This can go up to 10% of Bazel's analysis time. |
cgrindel
approved these changes
Oct 18, 2026
Collaborator
|
LGTM. I left it unmerged so that @aiuto can take a look. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
f not in ctx.files.excludesscans the list of excluded files for every source file, so analyzing apkg_filestarget takes time proportional to the product of the number of sources and excludes. This change checks against a dict built once from the excludes instead.Bazel's own
//:dist-srcshas 14,411 sources and 8,807 excludes, which amounts to about 127MFilecomparisons on a single thread at the end of analysis. With this change, the cold analysis wall time ofbazel build --nobuild //src/...in the Bazel repo drops from 14.40s to 13.92s on average (n=6,--lockfile_mode=off).