-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
8058176: [mlvm] tests should not allow code cache exhaustion #2523
Conversation
👋 Welcome back enikitin! A progress list of the required criteria for merging this PR into |
@lepestock The following label 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 list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
As suggested by @iignatev, cleaned off WhiteBox changes in favour of management JMX beans, resulting in much cleaner solution. |
@@ -63,10 +66,21 @@ | |||
|
|||
private static final boolean USE_THROW_CATCH = false; // Test bugs | |||
|
|||
private static final MemoryPoolMXBean CODE_CACHE_MX_BEAN = ManagementFactory |
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.
does it work w/ both -XX:+SegmentedCodeCache
and -XX:-SegmentedCodeCache
?
If I remember correctly (@TobiHartmann , please correct me if I'm wrong), CodeCache
pool exists when SegmentedCodeCache
is disabled, when it's enabled, you will have 3 different pools (one for each "CodeHeap"), and here we would need to use one for non-nmethod
codeheap.
-- Igor
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.
Thanks for the info about the segmented code cache. I did some research and found that the opposite is true - both nmethod pools ('profiled' and 'non-profiled') are growing along with the MH graph growth. This is supported by the specification for non-method code heap at:
Please check the the fixed version.
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.
o/c they grow, b/c we use them for compiled code and if there is no space in non-nmethod heap, we use them for adapters as well, so I guess that the growth that you see is already after non-nmethod heap got exhausted. I'd recommend you simply use the sum of all available code-heaps (this will increase the possibility of false-positive results due to segmentation, but I don't think it matters much here).
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.
Well, seems like rebalancing doesn't works that good. Here's a sample failure with plenty of free space in the non-nmethods heap:
[8.230s][warning][codecache] CodeHeap 'non-profiled nmethods' is full. Compiler has been disabled.
[8.230s][warning][codecache] Try increasing the code heap size using -XX:NonProfiledCodeHeapSize=
Java HotSpot(TM) 64-Bit Server VM warning: CodeHeap 'non-profiled nmethods' is full. Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code heap size using -XX:NonProfiledCodeHeapSize=
CodeHeap 'non-profiled nmethods': size=8192Kb used=8191Kb max_used=8191Kb free=0Kb << Exhausted
CodeHeap 'profiled nmethods': size=8192Kb used=8191Kb max_used=8191Kb free=0Kb << Exhausted
CodeHeap 'non-nmethods': size=102400Kb used=18343Kb max_used=18343Kb free=84056Kb << 84Mb of free space
# ERROR: Caught exception in Thread[Thread-41,5,MainThreadGroup]
...
# ERROR: Caused by: java.lang.VirtualMachineError: Out of space in CodeCache for method handle intrinsic
The sum monitoring won't help here either. I've added non-nmethods heap to the monitoring, just to be sure.
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.
hm... that can mean that there is a product bug (or my recollections about code heaps aren't as good as I thought).
@TobiHartmann , @iwanowww, could you please take a look? Evgeny's observations suggest that method handle intrinsics use non-profiled nmethods
and profiled nmethods
heaps and not non-nmethods
heap despite the fact that the last one has plenty of free space. my understanding is/was that we should have used non-nmethods
heap for MH intrinsic 1st and if it's exhausted start to use the other heaps.
Thanks,
-- Igor
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 a compelling reason why method handle linkers have to be nmethods and live in 'profiled'/'non-profiled' code heaps. I think the reason why it works that way now is the linkers are treated as ordinary native wrappers (since linker methods are just signature-polymorphic native static methods declared on java.lang.invoke.MethodHandle
class). But native wrappers are represented as nmethod
s for a reason: they can be unloaded along with the class.
It's not the case with MH linkers which aren't unloaded at all.
Please, file an RFE if you find it desirable to put MH linkers into 'non-nmethods' heap.
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.
Raised the RFE: https://bugs.openjdk.java.net/browse/JDK-8263377
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.
Here's the rationale behind the non-nmethods heap monitoring: the test i2c_c2i that fills up that heap. The test was started with 8MB per each heap, and consumed all the non-nmethods one. The consumption speed diminishes quickly after ~10 MB, but with the limits of 8 MB (stated in the case) we can hit the Error:
Heaps statistics: [non-nm: 1.8 MiB : 22%][profiled: 781.3 KiB : 9%][non-profiled: 189.3 KiB : 2%]
...
Heaps statistics: [non-nm: 8.0 MiB : 99%][profiled: 3.0 MiB : 37%][non-profiled: 8.0 MiB : 99%]
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.
Raised the RFE: https://bugs.openjdk.java.net/browse/JDK-8263377
do you plan to change MHTransformationGen:: isCodeCacheEffectivelyFull
after/if 8263377 got integrated?
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.
Raised the RFE: https://bugs.openjdk.java.net/browse/JDK-8263377
do you plan to change
MHTransformationGen:: isCodeCacheEffectivelyFull
after/if 8263377 got integrated?
Raised the https://bugs.openjdk.java.net/browse/JDK-8263398 to not forget about it.
@@ -88,6 +102,12 @@ public static MHMacroTF createSequence(Argument finalRetVal, Object boundObj, Me | |||
List<MHTFPair> pendingPWTFs = new LinkedList<MHTFPair>(); | |||
|
|||
for ( int i = nextInt(MAX_CYCLES); i > 0; i-- ) { | |||
if (isCodeCacheEffectivelyFull()) { | |||
Env.traceNormal("Not enought code cache to build up MH sequences anymore. " + | |||
" Has only been able to achieve " + (MAX_CYCLES - i) + " out of " + MAX_CYCLES); |
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.
given nextInt(x)
returns a random number from [0; x]
, we might have achieved more (or less) MAX_CYCLES - i
, i.e. that part of the message is incorrect, I'd just remove 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.
Fixed by extracting the generated random number first.
NON_SEGMENTED_CODE_CACHE_POOL.ifPresent(pool -> check.accept(pool, 2_000_000)); | ||
NON_NMETHODS_POOL.ifPresent(pool -> check.accept(pool, 1_000_000)); | ||
PROFILED_NMETHODS_POOL.ifPresent(pool -> check.accept(pool, 1_000_000)); | ||
NON_PROFILED_NMETHODS_POOL.ifPresent(pool -> check.accept(pool, 1_000_000)); |
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.
could you please introduce a (or two) static final field for these constants and use them here?
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.
could you please introduce a (or two) static final field for these constants and use them here?
Fixed in the new version.
@lepestock 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 16 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 (@iignatev) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@lepestock |
Are we integrating this? I thought to sponsor, but wanted to check if everyone is in agreement this change is fine. |
Fine w/ me. |
hm... I guess no one else wants to share their opinion, so I'll take it as an agreement and /sponsor |
/sponsor |
@iignatev @lepestock Since your change was applied there have been 411 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 4c83d24. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Another approach to the JDK-8058176 and #2440 - never allowing the tests hit CodeCache limits. The most significant consumer is the MH graph builder (the MHTransformationGen), whose consumption is now controlled. List of changes:
Testing: the whole vmTestbase/vm/mlvm/ in win-lin-mac x86.
Progress
Issue
Reviewers
Download
To checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/2523/head:pull/2523
$ git checkout pull/2523
To update a local copy of the PR:
$ git checkout pull/2523
$ git pull https://git.openjdk.java.net/jdk pull/2523/head