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
JDK-8303154: Investigate and improve instruction cache flushing during compilation #12877
Conversation
👋 Welcome back dafedafe! A progress list of the required criteria for merging this PR into |
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. As we discussed, please file a follow-up RFE for the remaining investigations around excessive icache flushing.
@dafedafe This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. 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 264 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TobiHartmann, @vnkozlov) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
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.
Did you look on how many times we flush ICache during adapters generation?
It has most numerous cases when I looked on it:
"CodeCache::commit() is also used for adapters. But adapters uses RuntimeBlob which calls CodeBuffer::copy_code_to()."
I thought we would remove flush from CodeCache::commit() and not from copy_code_to().
@vnkozlov the ICache flushing was called 1596 times during adapters generation. You're right, these are by far the most calls and the flush calls are also performed twice in these cases, once in
I thought it would make more sense to keep the flush in |
…r::copy_code_to()
@vnkozlov @TobiHartmann I pushed the changes if you want to have a look at them again. Thanks a lot! |
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. What are new numbers of of calls to flush the ICache?
@dafedafe I look on stack traces you collected. Please look on this:
|
The total number of flushes for the HelloWorld on Mac OSX aarch64 go from 3569 to 2756 on C1 (22.8% improvement) and from 3572 to 2685 on C2 (24.1% improvement). |
Yes, thanks a lot @vnkozlov! I've removed the flushing there too. |
Nice! Good work. Now please thoroughly test it. |
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 catch, Vladimir. New version looks good to me too.
This fix includes some changes to |
@dafedafe as followup RFE (I don't want to add more changes to this PR) look on all uses of |
FTR, the follow-up RFE is JDK-8303971. |
Sure! Thanks for the hint @vnkozlov. |
Hi, I performed tier1-3 tests on linux-riscv64 boards, result looks good. |
@RealFYang thank you very much for running the tests! |
HI, tier1-2 tests on ARM32 are OK! |
@bulasevich thanks a lot for testing! |
@TobiHartmann @vnkozlov thanks a lot for your reviews! |
/integrate |
/sponsor |
Going to push as commit b7945bc.
Your commit was automatically rebased without conflicts. |
@TobiHartmann @dafedafe Pushed as commit b7945bc. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
It was noticed that we flush the instruction cache too much for a single C1 compilation. The same is true for the C2 compilation.
There are several places in the code where the instruction cache is called and many of them are very intertwined (see bug report).
This PR is meant to be a "minimum" set of changes that improve the situation without introducing excessive extra information to keep track of the origin of the call through call stacks. This is done by avoiding calls to flush the ICache:
Compilation::emit_code_epilog
CodeCache::commit
as flushing is done anyway when copying from the temporary buffer into the code cache inCodeBuffer::copy_code_to
. This results in flushing the ICache only once instead of 3 times for a C1 compilation and twice for a C2 compilation. Additionally this halves the number of flushes during adapters generation (lots of calls).SharedRuntime::generate_i2c2i_adapters
as this is called with a temporary buffer and an ICache flush is not neededThis change decreases the number of calls to flush the ICache for a simple Hello world program on Mac OSX aarch64 from 3569 to 2028 on C1 (43.2% improvement) and from 3572 to 1952 on C2 (45.4% improvement).
This fix includes changes for x86_32/64 and aarch64, which I could test thoroughly but also for arm and riscv, for which I would need some help with testing.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12877/head:pull/12877
$ git checkout pull/12877
Update a local copy of the PR:
$ git checkout pull/12877
$ git pull https://git.openjdk.org/jdk pull/12877/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12877
View PR using the GUI difftool:
$ git pr show -t 12877
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12877.diff