← Back to Pull requests

Filter toolchains by target platform #10

Open
zbarsky-openai opened this pull request with 7569 lines diff across 142 files
View on GitHub
zbarsky-openai zbarsky-openai commented on Sep 09, 2026 17:29 UTC
Author

Reject native toolchain declarations that cannot match the resolver's
target platform before configuring their target_settings. Follow
unconditional native aliases and use the existing constraint matching
semantics, including defaults. Keep normal analysis for configurable
aliases, malformed constraints, cycles, and declarations that inherit the
target platform's constraints. Debug mode retains all candidates so it
can explain rejections.

As with the existing requested-type filter, validation errors in
irrelevant declarations are deferred until those declarations are
needed. This includes errors in other attributes and alias visibility
or compatibility. The debug path retains eager validation.

Three baseline and three candidate full --nobuild runs, with identical
source/flags, warm repositories, fresh servers and a 56 GiB heap cap,
measured these medians:

| Metric | Before | After |
| --- | ---: | ---: |
| Configured targets | 8,388,497 | 5,494,561 |
| Analysis time | 217.567 s | 194.326 s |
| Wall time | 259.402 s | 233.876 s |
| Retained heap | 27,406 MB | 24,573 MB |

Configured targets fell 34.5%, analysis time 10.7%, and retained heap
10.3%. Peak RSS was essentially unchanged. Individual analysis samples
were [222.022, 217.567, 215.736] s before and
[196.611, 194.326, 193.475] s after. Target counts were stable in every
repeat. Created actions (7,751,549), retained actions (7,741,504), and
output artifacts (9,231,190) were unchanged.

The benchmark used the release-20 source at
1fd51d36c59ad0e765df05b465b0e2209801f167 with identical diagnostic code in
both binaries. All six runs selected the same 117,710 targets, analyzed
the same 117,625, and encountered the same 85 pre-existing failures.
These were comparable partial analyses, not successful builds.

All 84 executed cases passed across RegisteredToolchainsFunctionTest,
SingleToolchainResolutionFunctionTest, ToolchainsForTargetsTest and
ToolchainResolutionFunctionTest. A native Python extension test passed.
Normalized runtime action comparisons matched on Linux x86_64, Linux
ARM64 and macOS ARM64; normalization removed only configuration hashes
from output paths and compared arguments, environment, inputs, outputs,
parameter files, execution platform, and action multiplicities.

Diff: 7569 lines (+5872 / -1697) across 142 files Reviewer: katre Review duration: 58347m
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.79) × (1 − Review Confidence (0.66)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.79 · 7569 lines diff across 142 files
0.79
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.35 · 1 substantive comment(s)
0.35
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
65%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Mass File Touch mass_file_touch
0.080
Real PR Conversation Timeline
2 items
katre katre approved these changes on Sep 10, 2026 14:26 UTC
Approved Reviewer

The core insight here seems to be (correct me if I am wrong) that you can read the constraints directly from the Target without actually doing the full resolution of ConfiguredTargetFunction, and potentially short circuit a lot of work.

This is something I considered a few years ago, but I wasn't sure if the gains were worthwhile. I think you've shown that they are.

My only real suggestion is to add some comments to RegisteredToolchainFunction clarifying what the checks are doing and why.

My biggest concern is whether this is adding new skyframe edges or just re-allocating the ones that existed before this change. This isn't an issue in bazel, but google's internal distributed skyframe is very sensitive to the number of edges as well as the number of nodes, and so could potentially prove a problem there. I believe checking this before and after your change with bazel dump --skyframe=summary should be sufficient.

I'd love to see this merged back to mainline bazel.

Reviewers
Assignees
zbarsky-openai zbarsky-openai
Labels
risk: low confidence: 65.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 78.5% (HIGH) · Higher = larger blast radius
78.5%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 65.5% · Lower = rushed or shallow review
65.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 27.1% · Safe to merge
27.1%
Repository