Skip to content

Conversation

@fmeum
Copy link
Collaborator

@fmeum fmeum commented Jan 7, 2026

BuiltinRestriction currently accounts for 10-20% of the total CPU time for bazel build --nobuild //src:bazel. This is improved by avoiding the repeated creation of "non-visible" RepositoryName objects, which trigger a SpellChecker computation. Instead, the apparent repo names, which are in fact either module names or legacy WORKSPACE repo names that no longer matter in Bazel 9 and later, are turned into canonical repo name prefixes by appending a +.

Note that there is still overhead in the 2-3% range even after this change due to repeated linear searches as well as repeated recreations of allowlists in the check_private_api C++ Starlark API.

This PR also closes a loophole where a module could give itself a repo name of e.g. bazel_build_rules_android to then use private APIs.

BuiltinRestriction currently accounts for 10-20% of the total CPU time for `bazel build --nobuild //src:bazel`. This is improved by avoiding the repeated creation of "non-visible" `RepositoryName` objects, which trigger a `SpellChecker` computation. Instead, the apparent repo names, which are in fact either module names or legacy WORKSPACE repo names that no longer matter in Bazel 9 and later, are turned into canonical repo name prefixes by appending a `+`.

Note that there is still overhead in the 2-3% range even after this change due to repeated linear searches as well as repeated recreations of allowlists in the `check_private_api` C++ Starlark API.
@fmeum fmeum marked this pull request as ready for review January 7, 2026 09:44
@fmeum fmeum requested a review from a team as a code owner January 7, 2026 09:44
@fmeum fmeum requested review from Wyverald, lberki and mai93 and removed request for a team and mai93 January 7, 2026 09:45
@github-actions github-actions bot added team-Configurability platforms, toolchains, cquery, select(), config transitions awaiting-review PR is awaiting review from an assigned reviewer labels Jan 7, 2026
Copy link
Member

@Wyverald Wyverald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Wyverald Wyverald added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jan 7, 2026
@copybara-service copybara-service bot closed this in cecc26b Jan 9, 2026
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jan 9, 2026
@meteorcloudy
Copy link
Member

@fmeum This change was rolled back at 7111cbf

@fmeum
Copy link
Collaborator Author

fmeum commented Jan 12, 2026

@meteorcloudy I sent a reland in #28217, which is in the process of being merged.

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

Labels

team-Configurability platforms, toolchains, cquery, select(), config transitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants