JIT: Fix truncated histogram likelihoods - #133990
AndyAyersMS wants to merge 2 commits into
Conversation
Truncated histograms assigned omitted probability to the first entry, artificially inflating its likelihood. Only normalize rounding error when the full histogram is returned. Fixes dotnet#133973 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
🟡 Changes recommended
Add value-histogram regression coverage and correct the shared class/method documentation.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes JIT PGO histogram likelihood normalization so truncated histograms no longer inflate the first result.
Changes:
- Normalize only complete class, method, and value histograms.
- Add class and method histogram regression tests.
- Update helper documentation and test configuration.
File summaries
| File | Summary |
|---|---|
src/tests/JIT/PGO/LikelyClass/LikelyClass.csproj |
Configures the JIT regression test. |
src/tests/JIT/PGO/LikelyClass/LikelyClass.cs |
Tests truncated, complete, and unknown-handle class/method histograms. |
src/coreclr/jit/likelyclass.cpp |
Corrects normalization and updates documentation; value-histogram regression coverage and neutral class/method wording remain needed. |
Review details
Suppressed comments (1)
src/coreclr/jit/likelyclass.cpp:328
- This shared return-value documentation is also used by
getLikelyMethods(see the “See documentation on getLikelyClasses above” note below), so describing the result as class records written topLikelyClassesis inaccurate for method histograms. Use neutral class/method wording so the contract is correct for both exported helpers.
// Number of likely class records written to pLikelyClasses
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Add deterministic regression coverage for truncated class/method and value histograms.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
src/coreclr/jit/likelyclass.cpp:453
- The value-histogram branch is also changed for the independently important case where more than eight constants are observed, but no regression test is included for profile-driven constant specialization with truncated data. Please add deterministic coverage (or a direct
getLikelyValuestest) that verifies the top value keeps its raw likelihood and does not trigger specialization after the truncation fix.
if (numberOfLikelyConst == h.countHistogramElements)
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
|
@EgorBo PTAL A couple hundred SPMI diffs, mostly cases where we no longer act on profile data since it is no longer artificially inflated. |
Fixes #133973
Truncated class, method, and value histograms transferred all omitted
probability to the first returned entry. This artificially inflated its
likelihood and could trigger unjustified guarded devirtualization or constant
specialization.
Only normalize rounding error when all histogram entries are returned.
Validation:
clr+libsbuildcompiles, and 7,773 fewer bytes overall
Performance:
The differing results reflect removal of an invalid speculative guard. This
change corrects profile probabilities rather than promising a uniform
throughput improvement.
Note
This pull request description was generated with GitHub Copilot.