Build Multidictionary's reverse index lazily #2260
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
artemcm
Resolves #2259.
Multidictionaryhas been updated to build the reverse index on the firstremoveOccurrences(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
keysContainingValuessince 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
MultidictionaryTestscover 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. TheMultidictionaryTests,ModuleDependencyGraphTests,DependencyGraphSerializationTestsand incremental suites pass.