Random: fast rand! for contiguous views of BitArray #65009
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 183 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.312
Real PR Conversation Timeline
1 comments
"Review active on #65009"
general
weight: 0.35
oscardssmith
Fixes #41862.
rand!(::BitArray)fills whole 64-bit chunks at once, but a view such asview(B, :)orview(B, 3:70)fell back to the generic loop, oneBoolat a time.This adds a method for
Base.FastContiguousSubArray{Bool,<:Any,<:BitArray}. Such a view coversone contiguous run of bits in the parent, so the method fills the chunks spanning that run
with
rand!(rng, view(chunks, ka:kb))and then restores the parent's bits outside the viewin the first and last chunk. Non-contiguous views still use the generic path.
Timing from the issue (Julia 1.13.4 with this method loaded, Windows x86_64):
Tests added in
stdlib/Random/test/runtests.jlcover view bounds at and around chunkboundaries (including a view inside a single chunk), parent bits outside the view staying
untouched, a contiguous view of a
BitMatrix, empty views, seeding reproducibility, andMersenneTwister/RandomDevice.Testing note: I don't have a source build of master. I loaded the new method into Julia
1.13.4's
Randomand ran 1.13.4's full Random test suite plus the new testset; all pass.AI disclosure: I wrote this change with help from Claude (Anthropic): it drafted the method,
the tests and this description. I reviewed every line and ran the tests above.