Use a scoped zeroing allocation for the HMAC pad #490
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 580 lines diff across 7 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.381
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #490"
general
weight: 0.35
Lukasa
Motivation:
Currently HMAC heap allocates twice per construction for temporary storage.
HMAC.init(key:)builds the inner and outer pads using twoSecureBytesallocations. This is a bottleneck for both HMAC and HKDF, which constructs an HMAC per output block. Both pads never escape the initializer, so neither needs to be on the heap at all. A scoped temporary allocation that zeroes after use does the same job with no allocations.Modifications:
Sendableannotation)Result:
HMAC<SHA256>.authenticationCode: was 5 allocations, now 3, ~20% faster.HKDF<SHA256>.deriveKey, 1 KiB output: was 170 allocations, now 104, ~30% faster.Benchmarks:
Credits:
This PR is a re-work of the original contribution by @ptoffy. The merge-commit will show him as a co-author.