-
Notifications
You must be signed in to change notification settings - Fork 5.1k
JIT: Ensure profile synthesis converges for trivial cases #116502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: Ensure profile synthesis converges for trivial cases #116502
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where the Gauss-Seidel profile synthesis does not converge for trivial flowgraph shapes by skipping unnecessary residual checks and adding a weight balance check instead.
- Fixed a typo in a comment within flowgraph.cpp.
- Adjusted the convergence logic in fgprofilesynthesis.cpp to check entry/exit weight balance when synthesis runs after the importer.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/coreclr/jit/flowgraph.cpp | Corrected a typo in a comment. |
src/coreclr/jit/fgprofilesynthesis.cpp | Updated solver logic to check weight balance for convergence. |
@@ -582,7 +582,7 @@ PhaseStatus Compiler::fgImport() | |||
} | |||
|
|||
// Now that we've made it through the importer, we know the IL was valid. | |||
// If we synthesized profile data and though it should be consistent, | |||
// If we synthesized profile data and thought it should be consistent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment typo has been fixed. This update improves clarity by correcting 'though' to 'thought'.
// If we synthesized profile data and thought it should be consistent, | |
// If we synthesized profile data and though it should be consistent, |
Copilot uses AI. Check for mistakes.
{ | ||
converged = true; | ||
converged = !m_comp->fgImportDone || m_comp->fgProfileWeightsConsistent(entryWeight, exitWeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider splitting this compound condition into separate if/else branches or adding inline comments to enhance readability and clarify the two distinct cases being handled.
converged = !m_comp->fgImportDone || m_comp->fgProfileWeightsConsistent(entryWeight, exitWeight); | |
// Case 1: If the importer is not done, we consider it converged. | |
if (!m_comp->fgImportDone) | |
{ | |
converged = true; | |
} | |
// Case 2: Check if the profile weights are consistent. | |
else if (m_comp->fgProfileWeightsConsistent(entryWeight, exitWeight) | |
{ | |
converged = true; | |
} | |
else | |
{ | |
converged = false; | |
} |
Copilot uses AI. Check for mistakes.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
cc @dotnet/jit-contrib, @AndyAyersMS PTAL. Small diffs from floating-point precision changes in block weights. CI failures dead-lettered and/or have missing logs -- I suspect they aren't related. Thanks! |
/ba-g unrelated infra failures |
While triaging regressions from profile maintenance work, I noticed profile repair passes regularly fail to converge and mark the profile as inconsistent, despite the weights clearly being consistent. This is because the Gauss-Seidel solver will only run for one iteration when a method doesn't have unnatural loops, but the first iteration's relative residual calculation is always too large to be considered converged. We should skip the residual checks for trivial flowgraph shapes to avoid this (like we already do during profile incorporation), but we still need some mechanism to detect if the weight coming out of a loop exceeds the weight into it; so far, I think checking method entry/exit weights for balance is sufficient.
Here's an example of the behavior this fixes:
This should improve TP a bit, as we won't needlessly run repair as often.