Repository navigation
fix(callgrind): model REP copies with calibrated bulk costs - #60
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
[Medium impact] The PR appears safe to merge; both previous findings are fixed, and no new actionable issues were found. SummaryAdds calibrated amd64 REP MOVS/STOS costs to the existing
Reviews (2) · Last reviewed commit: "fixup! fix(callgrind): model REP copies ..." · Reviewed by Greptile |
0505d81 to
09053ba
Compare
GuillaumeLagrange
left a comment
There was a problem hiding this comment.
lgtm, how do we plan to expose this? Experimental flag that will become on by default on next major if we're happy?
Replace per-element REP MOVS/STOS cycle estimates with measured hot-copy curves on amd64. Charge the calibrated marginal through the existing Ct/Cl counters and report only data L1 misses as Dr/Dw, retaining cache simulation, instruction counters, and all miss penalties. Enable the model with cache simulation and cycle estimation; --rep-bulk-cost=no restores the per-element accounting. Keep the output format unchanged and document mixed-counter, overlap, cache-residency, and vector-comparison limitations. The curves come from a Zen 5 calibration generated out of tree. Each curve includes the fixed REP startup cost measured against a no-REP baseline. Points that do not change the interpolated cost at any element multiple are dropped, so the table stores 2,567 points across 48 curves. Add default and legacy runtime regressions for zero-length copies, hot/cold counters, backward overlap, stores, and self-copy.
9db6684 to
9e5372d
Compare
yep, that's the plan |
The bulk curve covers L1-resident cost. Charging every L1 miss of a REP copy on top priced lines streamed from LL like isolated misses, which overstated large copies by an order of magnitude. Only accesses that miss LL are now reported for modeled REP instructions.
9e5372d to
7e853af
Compare
`--experimental-rep-bulk-cost` passes `--rep-bulk-cost=yes` to Callgrind, which 0codspeed13 rejects as an unknown option, so the run fails. 0codspeed14 adds the option (CodSpeedHQ/valgrind-codspeed#60), off by default: results without the flag do not change. Closes COD-4234 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary
--rep-bulk-cost=norestores legacy accounting. No new output events or format changes.Curve cost for aligned forward
rep movsb, in cycles:Verification
rep_bulkandrep_bulk_legacypass: zero-length, one-byte, hot and cold 10 KiB, backward overlap, stores, and self-copy.runtime_obj_skip_candruntime_obj_skip_underflowfail with and without this change.Modeling limits requiring review
This is a draft, not a claim of calibrated end-to-end speedups. Existing scalar/vector pricing is unchanged, so REP copies can score far cheaper than equivalent vector loops even where native timing does not agree.
The table was measured on Zen 5; the existing static instruction LUT is Zen 4. Calibration targets disjoint L1-resident buffers up to 16 KiB MOVS / 32 KiB STOS. Larger sizes extrapolate the final slope and keep existing miss penalties. Overlap performance is outside the calibration domain, although copy semantics are preserved. Mixed REP/non-REP Ct/Cl aggregation keeps the existing geometric-mean cross terms.
Dr/Dw become modeled miss-only references for supported REP instructions, not raw access counts.