-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8331087: Move immutable nmethod data from CodeCache #18984
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
Conversation
|
👋 Welcome back kvn! A progress list of the required criteria for merging this PR into |
|
@vnkozlov 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 14 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. ➡️ To integrate this PR with the above commit message to the |
|
@vnkozlov The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
| * @bug 8207355 | ||
| * @compile TestLinearScanOrder.jasm | ||
| * @run main/othervm -Xcomp -XX:+TieredCompilation -XX:TieredStopAtLevel=1 | ||
| * -XX:+IgnoreUnrecognizedVMOptions -XX:NMethodSizeLimit=655360 |
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 caught one check_cast<> issue during development but only on aarch64.
On x64 the test bailed out compilation before that because default NMethodSizeLimit was not big enough ((64*K)*wordSize = 524288).
| int consts_size () const { return int( consts_end () - consts_begin ()); } | ||
| int insts_size () const { return int( insts_end () - insts_begin ()); } | ||
| int stub_size () const { return int( stub_end () - stub_begin ()); } | ||
| int oops_size () const { return int((address) oops_end () - (address) oops_begin ()); } | ||
| int metadata_size () const { return int((address) metadata_end () - (address) metadata_begin ()); } | ||
| int scopes_data_size () const { return int( scopes_data_end () - scopes_data_begin ()); } | ||
| int scopes_pcs_size () const { return int((intptr_t)scopes_pcs_end () - (intptr_t)scopes_pcs_begin ()); } | ||
| int dependencies_size () const { return int( dependencies_end () - dependencies_begin ()); } | ||
| int handler_table_size () const { return int( handler_table_end() - handler_table_begin()); } | ||
| int nul_chk_table_size () const { return int( nul_chk_table_end() - nul_chk_table_begin()); } |
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.
Shift by one space to aline code.
| assert((data_offset() + data_end_offset) <= nmethod_size, "wrong nmethod's size: %d < %d", nmethod_size, (data_offset() + data_end_offset)); | ||
|
|
||
| // native wrapper does not have read-only data but we need unique not null address | ||
| _immutable_data = data_end(); |
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 can't use nullptr because VM expects not null address when it checks, for example, dependencies_begin() even so sizes are 0.
I used data_end() instead of nullptr in other places too.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java
Outdated
Show resolved
Hide resolved
|
Thank you, @dean-long, for review. I will collect (hopefully) more comments for next update before testing and pushing it. |
src/hotspot/share/code/nmethod.hpp
Outdated
| enum ResultStatus { | ||
| passed, | ||
| code_cache_full, | ||
| out_of_memory |
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.
Maybe out_of_c_heap_memory would be clearer? Or out_of_immutable_data_memory if immutable data may not always be malloc'ed.
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.
May be no_space_for_immutable_data.
| nmethod_entry_patch_offset, | ||
| nmethod_mirror_name, | ||
| failed_speculations); | ||
| nmethod::ResultStatus result_status; |
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.
Please propagate the new out_of_memory result throughout JVMCI (e.g. in JVMCI::CodeInstallResult enum and HotSpotVMConfig.getCodeInstallResultDescription method).
|
@dean-long and @dougxc I am thinking may be I should not bailout when What do you think? |
|
It only makes sense if the immutable data heap is not also used for other critical resources. If malloc or metaspace were used as the immutable data heap, normally failures in those heaps are fatal, because other critical resources (monitors, classes, etc) are allocated from there, so any failure means the JVM is about to die. There's no reason to find a fall-back method to allocate a new nmethod in that case. |
|
Just to be clear @dean-long , you're saying failure to allocate immutable data in the C heap should result in a fatal error? Makes sense to me as the VM must indeed be very close to crashing anyway in that case. It also, obviates the need for propagating |
|
Update:
|
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. Did you measure any impact on performance (potentially due to improved code density)?
What's left for JDK-7072317?
I wonder if the CHECKED_CAST changes shouldn't go into a separate RFE.
I hadn't thought it through that far, actually. I was only pointing out that the proposed fall-back:
isn't worth the trouble. But making the C heap failure fatal immediately is reasonable, especially if it simplifies JVMCI error reporting. |
|
JVMCI changes now look good to me. |
Thank you, @TobiHartmann, for review.
Make Relocation info (10% of nmethod size) immutable by moving all encoded pointers (external words and others, which we need to patch in Leyden when loading cached code) from it into separate mutable section.
No, I want clear information which cast failed instead of trying to reproduce very intermittent failure like this: JDK-8331253. When you have several |
|
Thank you, Dean, Doug and Tobias for reviews. |
|
/integrate |
|
Going to push as commit bdcc240.
Your commit was automatically rebased without conflicts. |
Move immutable nmethod's data from CodeCache to C heap. It includes
dependencies, nul_chk_table, handler_table, scopes_pcs, scopes_data, speculations. It amounts for about 30% (optimized VM) of space in CodeCache.Use HotSpot's
os::malloc()to allocate memory in C heap for immutable nmethod's data. Callvm_exit_out_of_memory()if allocation failed.Shuffle fields order and change some fields size from 4 to 2 bytes to avoid nmethod's header size increase.
Tested tier1-5, stress,xcomp
Our performance testing does not show difference.
Example of updated
-XX:+PrintNMethodStatisticsoutput is in JBS comment.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18984/head:pull/18984$ git checkout pull/18984Update a local copy of the PR:
$ git checkout pull/18984$ git pull https://git.openjdk.org/jdk.git pull/18984/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18984View PR using the GUI difftool:
$ git pr show -t 18984Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18984.diff
Webrev
Link to Webrev Comment