Regex: Add a lazily-populated cache for S_setup_EXACTISH_ST #25014
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.49) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.49 · 328 lines diff across 4 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
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #25014"
general
weight: 0.35
demerphq
S_setup_EXACTISH_ST()produces a quicknext_matchable_infofilter that is used to efficiently scan for positions before attempting a full pattern match. In blead, this filter is generated during regex execution and does not persist from one execution to another.S_setup_EXACTISH_ST()does a fair amount of work, making its contribution to the runtime of pattern matching not insignificant. (Likely more noticeable for simpler patterns though.)On the assumption that a regex that runs once will likely run again, it should be worthwhile to cache the result for future runs to retrieve.
This commit adds a lazily-allocated & populated cache for EXACTish regnodes.
EXACTFLnodes are excluded from the cache, as the result ofS_setup_EXACTISH_STis dependent upon runtime locale and could conceivably change from one call to the next.Using a pathological example of
my $x = "xy" x 100_000_000; while ($x =~ /x+y/g) {},perf statson blead looks something like this:with
S_setup_EXACTISH_STmaking a significant contribution:(That is excessive,
S_setup_EXACTISH_STis more likely to appear in the lower single digits.)With the cache added:
Closes #24480
-------------------------------------------------------------------------------