← Back to Pull requests

Split the `BroadcastStyle` method to avoid invalidations #231

Closed
unknown closed this pull request without merging on Oct 24, 2026 18:35 UTC
View on GitHub
unknown unknown commented on Oct 24, 2026 12:36 UTC
Author

The BroadcastStyle method for FixedSizeArrayDims and their views has a Union of both signatures:

function Base.BroadcastStyle(::Union{Type{<:(FixedSizeArrayDims{T, N, D, Mem} where {T, D})},
                                     Type{<:(SubArray{T, N, <:FixedSizeArrayDims{T, N, <:Any, Mem}} where {T})}}) where {N, Mem}

When the package is loaded, this method invalidates compiled code that calls BroadcastStyle of unrelated types. This PR splits it into two methods with the same bodies, one per signature, which do not.

Found via the invalidations check of trixi-framework/Trixi.jl#3357, which adds FixedSizeArrays.jl as a dependency. With @snoop_invalidations using Trixi on Julia 1.10:

| | invalidations |
|---|---|
| Trixi.jl main (without FixedSizeArrays.jl) | 1863 |
| trixi-framework/Trixi.jl#3357 with FixedSizeArrays.jl v1.5.0 | 1875 |
| trixi-framework/Trixi.jl#3357 with this PR | 1867 |

The 8 removed invalidations are all BroadcastStyle of Tuple types, e.g.:

MethodInstance for Base.Broadcast.BroadcastStyle(::Type{<:Tuple})
MethodInstance for Base.Broadcast.BroadcastStyle(::Type{<:NTuple{5, Any}})
MethodInstance for Base.Broadcast.BroadcastStyle(::Type{<:Tuple{Any, Any, Any}})
...

The remaining 4 come from the method for views. They are BroadcastStyle(::Type{SubArray}), combine_styles(::SubArray, ...) and materialize!(::SubArray, ...) compiled for abstract SubArrays. Any BroadcastStyle method for views would invalidate these. The cconvert method only replaces a method of StaticArrays.jl as the root of the same invalidations and adds none.

The broadcast style is unchanged, e.g. for view(a, :, :), view(a, 1:2, :) and view(a, :, 2) (which keeps DefaultArrayStyle{1} as before) of a FixedSizeArray, and for views of arrays with static dimensions. The existing test of the style of views (test/static_dims.jl) still passes. The tests pass on Julia 1.10 and 1.12.

🤖 Generated with Claude Code

Diff: 252 lines (+189 / -63) across 3 files Reviewer: giordano Review duration: 358m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 252 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
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.331
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #231"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.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: 39% (MEDIUM) · Higher = larger blast radius
39%
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: 60.5% · Lower = rushed or shallow review
60.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: 15.4% · Safe to merge
15.4%