Avoid allocations for short string operations #1433
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 219 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.323
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1433"
general
weight: 0.35
davidhewitt
Summary
Stringallocation.Benchmarks
Local Apple Silicon release builds, measured in 10 alternating before/after pairs.
String operations compare
78cb6ac8(upstream base) withd1b68fb8(the first PR commit).Timings include the Python loop, with 500,000 iterations per run.
| Workload | Base | PR | Change in elapsed time |
| --- | ---: | ---: | ---: |
| Short ASCII concatenation | 34.5 ns | 25.2 ns | −27% |
| Short Unicode concatenation | 33.9 ns | 24.4 ns | −28% |
| Short ASCII repetition | 39.1 ns | 30.7 ns | −21% |
| Short Unicode repetition | 39.4 ns | 30.7 ns | −22% |
| Dict lookup with an inline string key | 40.1 ns | 38.1 ns | −4% |
| 48-byte concatenation | 41.8 ns | 39.7 ns | −5% |
| Integer addition control | 13.2 ns | 13.3 ns | Flat |
Allocation counts confirmed one fewer heap allocation per short concatenation or repetition.
Dump loads compare
d1b68fb8withbb7aa67b, which adds the deserialization change.Both builds loaded the same snapshot bytes.
| Snapshot | Before | After | Change in elapsed time |
| --- | ---: | ---: | ---: |
| 50,000 inline string entries | 1.10 ms | 0.75 ms | −32% |
| Checked-in v17 fixture | 194 µs | 194 µs | Flat |
Tests
cargo test -p monty --lib --test string_identity --test dump_compatcargo run -p monty-datatest -- str__ --skip run_test_cases_cpythonmake format-rsandmake lint-rs