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
8272873: C2: Inlining should not depend on absolute call site counts #5238
Conversation
|
@veresov |
@veresov |
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.
I don't see InlineFrequencyCount
flag in java
man page so you don't need to fix it.
@@ -36,7 +36,7 @@ | |||
import jdk.test.lib.Platform; | |||
public class IntxTest { | |||
private static final String FLAG_NAME = "OnStackReplacePercentage"; | |||
private static final String FLAG_DEBUG_NAME = "InlineFrequencyCount"; | |||
private static final String FLAG_DEBUG_NAME = "BciProfileWidth"; |
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.
Why this addition for BciProfileWidth
?
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.
This test requires any diagnostic intx flag. I just found the first available.
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.
Got it.
"Ratio of call site execution to caller method invocation") \ | ||
range(0, max_jint) \ | ||
\ | ||
product_pd(intx, InlineFrequencyCount, DIAGNOSTIC, \ |
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.
You need to file CSR to remove product flag.
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.
It's a diagnostic flag, so it doesn't need a CSR.
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.
Right, I missed that.
Please run mach5 testing too. |
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.
Good.
Do testing.
@veresov This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 22 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
@vnkozlov I ran mach5 with this before. But, let me to do it again to make sure there are no unpleasant surprises. |
Nice finding, Igor! It looks like 2 unrelated changes ( |
Well it (the change to the inlining heuristic) removes the last mention of |
Are there any performance regressions worth mentioning? |
No, no real regressions. The counters don't decay, both numbers essentially come from an MDO, which currently doesn't decay. |
@vnkozlov The testing is squeaky clean. |
It looks like we still have UseCounterDecay, which used to trigger decay in older compilation policies. Is that flag obsolete now and replaced by something better? It seems like that's part of the reason InlineFrequencyCount is now less useful, because the counts no longer decay. |
Yeah, |
Btw, counters in an MDO never decayed. What did decay were main invocation counters, and that was primarily a part of the compilation / code cache management policy. |
@iwanowww & @dean-long Good to go with this? |
How did the old value of InlineFrequencyRatio=20 ever make sense? Unless the call site is virtual and is calling a different method, it seems like the ratio would be <= 1, and a ratio > 1 would mean we are inlining the wrong method. |
A > 1 ratio means the call site is evaluated more than once per invocation - it's in a loop. So 20 means that the call site should be a loop with more than 20 iterations. It kind of made sense. The current value of 0.25 means that we'll try to inline call sites that are evaluated in at least 25% of the invocations of the caller. |
Thanks, guys, for the reviews! |
/integrate |
Going to push as commit 673ce7e.
Your commit was automatically rebased without conflicts. |
@veresov That makes sense now. I incorrectly assumed invoke_count was for the callee, not the caller. |
C2 considers absolute call site counts in its inlining decisions, which seems very wrong considering the asynchronous nature of profiling and background compilation (See InlineTree::should_inline()). It causes substantial over-inlining, which in presence of a depth-first inlining can lead to an early cut off. It also is inherently unstable. C2 already uses call frequency as an additional factor and it's better to consider only that in the inlining heuristic. I did extensive benchmarking it yielded almost no losses and single-digit wins (up to 5%) on some benchmarks. I think it's safe to remove/deprecate InlineFrequencyCount and continue using InlineFrequencyRatio instead. I found that converting the frequency computation to FP and setting InlineFrequencyRatio=0.25 (inline a method that is called a least 25% of the time) works best.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5238/head:pull/5238
$ git checkout pull/5238
Update a local copy of the PR:
$ git checkout pull/5238
$ git pull https://git.openjdk.java.net/jdk pull/5238/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5238
View PR using the GUI difftool:
$ git pr show -t 5238
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5238.diff