-
Notifications
You must be signed in to change notification settings - Fork 732
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
Change inliner estimate code size heuristic #20904
base: master
Are you sure you want to change the base?
Conversation
1e3bb08
to
97abe2e
Compare
Performance testing has shown no harmful effects of this change in other cases, and it does clearly help the test case that was estimating an order of magnitude more than it inlined. So I am taking the WIP off. |
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.
Looks good to me.
Perhaps it's worth mentioning about the two new env vars in the description of the PR, which can serve as documentation.
if (inlineAnyway && !calleeHasNonColdCalls) | ||
{ | ||
_optimisticSize = origOptimisticSize; | ||
// This resetting is probably needed n this path since we are inlining despite exceeding some condition/threshold |
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.
Small typo: n --> on
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.
Fixed, thanks
Do not reset the _analyzedSize value if there was a large callee or there was estimation failure for some other reason. Keep track of all the code we have analyzed (including code that we estimated and then discarded) so that we do not have an undefined amount of estimating on a given top level callee. Introduce an "allowance" factor that gets applied on the size threshold to separate how much we are allowed to analyze and how much we are allowed to bring in as inlined call graph. This commit should limit the amount of code we are allowed to analyze to be a factor no more than 2x of what we we are allowed to bring in to the compiled method via inlining. Added a new env var TR_AnalyzedAllowanceFactor that allows a user to specify the factor by which we multiply the original estimate size threshold to control how much we can analyze even with backtracking. Added a new env var TR_GraceInliningThreshold that controls how big a callee is allowed to be, in order to be inlined even if the call graph size estimate is exceeded. Misc. cleanups: Fixed an inconsistency in how we reset variables during backtracking Renamed _optimisticSize to _analyzedSize since it is less confusing Fixed a typo in a variable name Fixed some white spaces Signed-off-by: Vijay Sundaresan <[email protected]>
97abe2e
to
2a2ccc3
Compare
I have added the description, thanks |
jenkins test sanity all jdk21 |
During the inlining optimization, there is a phase named estimate code size, that essentially collects the methods in the call graph of the top level callee that ought to be inlined. This estimation has a size threshold that limits the size of the call graph that will be analyzed, in order to prevent the estimation from taking too much cpu and memory. As per the original implementation, if the estimation looked at a call graph that has bytecodes that add up to more than the size threshold, this would cause the top level callee to not be inlined.
However, there was a "backtracking" mechanism added subsequently (still many years ago), that allowed us to skip over some very large parts of the call graph after estimating it, i.e. skip that part of the call graph from what gets considered for inlining. This allows the estimation to consider some other parts of the call graph that normally won't have been considered, and subsequently cause those other parts of the call graph to potentially get inlined.
This backtracking mechanism during estimation can cause a lot more (in one case we were running, it was an order of magnitude more) code to be estimated, but only a fraction of that code gets inlined in the end. In this PR, we are aiming to cap the amount of code that can be estimated, without hampering how much gets inlined in the end. So, this PR should save on the amount of cpu and memory taken by the estimation logic in some cases with very large call graphs that were also backtracking a lot.
Added a new env var
TR_AnalyzedAllowanceFactor
that allows a user to specify the factor by which we multiply the originalestimate size threshold to control how much we can analyze even with backtracking.
Added a new env var
TR_GraceInliningThreshold
that controls how big a callee is allowed to be, in order to be inlined even if the call graph size estimate exceeds the threshold.