← Back to Pull requests

Build Multidictionary's reverse index lazily #2260

Open
unknown opened this pull request with 168 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 09, 2026 02:15 UTC
Author

Resolves #2259.

Multidictionary has been updated to build the reverse index on the first removeOccurrences(of:) and maintain it from then on. It's stored inline as an optional, so copies keep value semantics. Its behavior is unchanged for every caller.

Alternatively, the reverse index could be built on the first access of keysContainingValues since it's public API, but since that was only accessed in assertions, it would make debug builds pay the cost more often.

Measured results:

| Measurement | Before | After |
|---|---|---|
| Deserializing the priors of a generated 2,000-file module (12.4 MB; median of 7 release runs) | 0.96 s | 0.43 s (−56%) |
| Incremental planning of the production app, four interleaved runs with the same priors, measured with an earlier version of this change | 9.86 to 9.99 s | 7.36 to 8.60 s (about −2.4 s, −24%) |

In Xcode, this is on the critical path of every edit ("Planning Swift module" took 12.5 s in each one-line-edit build of the app).

Testing: the new MultidictionaryTests cover lookups before the index exists, inserting and removing after it's built, and copies with and without it. Behavior is unchanged, so they also pass without the change. The MultidictionaryTests, ModuleDependencyGraphTests, DependencyGraphSerializationTests and incremental suites pass.

Diff: 168 lines (+126 / -42) across 2 files Reviewer: artemcm Review duration: 31489m
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.35) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 168 lines diff across 2 files
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
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
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.307
Real PR Conversation Timeline
1 comments
"Review active on #2260"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 43.0% 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: 35.1% (MEDIUM) · Higher = larger blast radius
35.1%
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: 43.0% · Lower = rushed or shallow review
43.0%
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: 20.1% · Safe to merge
20.1%