Repository navigation
fix(callgrind): model REP copies with calibrated bulk costs - #60
Draft
not-matthias wants to merge 2 commits into
Draft
not-matthias wants to merge 2 commits into
not-matthias wants to merge 2 commits into
Conversation
Replace per-element REP MOVS/STOS cycle estimates with measured hot-copy curves on amd64. Charge the calibrated marginal through existing Ct/Cl counters and report only REP data misses, retaining cache simulation, instruction counters, and all miss penalties. Enable the model with cache and cycle estimation by default; --rep-bulk-cost=no preserves legacy accounting. Keep the output format unchanged and document mixed-counter, overlap, cache-residency, and vector-comparison limitations. Add default and legacy runtime regressions for zero-length copies, hot/cold counters, backward overlap, stores, and self-copy.
Describe the measured offset-eight class precisely rather than implying every matching unaligned pointer pair selects that curve.
Merging this PR will improve performance by 10.56%
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--rep-bulk-cost=norestores legacy accounting. No new output events or downstream format changes.Verification
Modeled cycles per copy, including the same loop overhead:
Modeling limits requiring review
This is deliberately a draft, not a claim of calibrated end-to-end speedups. The native 10 KiB comparison was 34.97 ns REP versus 41.46 ns AVX2, whereas the new score favors REP by about 22x. At 1 KiB native AVX2 is faster, but the model favors REP. Existing scalar/vector pricing is unchanged.
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 retain existing miss penalties. Overlap performance is outside the calibration domain, although copy semantics are preserved. Held-out L1 samples at least 1 KiB have 0.203% median absolute relative error but 65.1% p95 and 154.8% maximum error; smaller sizes also have substantial relative-error outliers. Mixed REP/non-REP Ct/Cl aggregation retains the existing geometric-mean cross terms.
Dr/Dw become modeled miss-only references for supported REP instructions, not raw access counts. Results across this model boundary should not be interpreted as application performance changes.