-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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-8318016: Per-compilation memory ceiling #16220
JDK-8318016: Per-compilation memory ceiling #16220
Conversation
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
e2ca348
to
9c2b498
Compare
/label add hotspot-compiler |
@tstuefe |
@tstuefe |
3312263
to
9cddbec
Compare
c39c0c7
to
e807fec
Compare
e807fec
to
976d011
Compare
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.
That looks good to me.
Have you done any stress testing? Maybe running compile the world with a low memory limit.
@@ -368,6 +395,20 @@ void CompilationMemoryStatistic::on_end_compilation() { | |||
arena_stat->print_on(tty); | |||
tty->cr(); | |||
} | |||
|
|||
// Store result | |||
// For this to work, we must call on_end_compilatio()n at a point where |
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.
Typo: on_end_compilatio()n
@tstuefe 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 68 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 |
Many thanks @rwestrel . I did stress testing by adding a random (low) limit and running GHAs with it. I also ran with -Xcomp -Xbatch. I found a bunch of missing bailout chains, which I took care of before posting this PR (https://bugs.openjdk.org/browse/JDK-8318445, https://bugs.openjdk.org/browse/JDK-8318183). But there are more (e.g. #16375). We have been discussing a better way to care for these errors (I should have done this on the mailing list, sorry) and maybe introduce a semi-automatic way. Experiments of mine are here: #16289 - but I try to find a way that is less invasive. Finally, there is #16247, which adds better diagnostic information to the hs-err file when we miss a bailout. Bottom line, there are still outstanding issues with missing bailouts, and possibly a better solution at some point. In my view this does not prevent this RFE from going forward. |
Thanks for the details. That sounds reasonable to me. |
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.
That's a very useful feature, the implementation looks good to me. I've submitted some testing and will report back once it passed.
All tests passed. |
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
Many thanks @TobiHartmann! /integrate |
Going to push as commit 0461d9a.
Your commit was automatically rebased without conflicts. |
This RFE introduces a new compile command to limit memory usage per compilation. It complements and is based upon the JIT memory statistic introduced with https://bugs.openjdk.org/browse/JDK-8317683.
This new memory limit is applied during compilation for either C1 or C2. It has one of two modes:
Usage
The compile command takes the form
-XX:CompileCommand:MemLimit,<method>,<memory size>[~<option>]
The memory size that can be specified as usual. The command also takes an optional trailing option, separated from the memory size by a tilde (odd choice but needed because of https://bugs.openjdk.org/browse/JDK-8318214).
The
<suboption>
can be eithercrash
orstop
and distinguishes between the aforementioned modes. If omitted, the default is "stop".Since
MemLimit
is based on the JIT statistic, it is implicitly enabled, so there is no need to explicitly enable it withMemStat
.Usage examples:
The JIT statistic table (printed either at VM shutdown or via
jcmd <pid> Compiler.memory
) now has a new column "result" that shows if the compilation was completed successfully or had an error or an oom:Implementation notes
The crash variant works immediately.
The stop variant works delayed: If arena memory reaches the limit in the scope of a compilation, we signal the Compile object (
Compile
for c2,Compilation
for c1) that an oom has occurred.For C1, we set the bailout string right here. That causes the C1 compilation to fail at the next bailout check.
For C2, we cannot just set
Compile::_failure_reason
since I found that the C2 is not well prepared to bail out from wherever it is tested. So I incorporated the oom check in the nodelimit check C2 does. Note that even that needs some preparatory work (see #16205, a prerequisite for this RFE).Due to this delay, the actual memory used per compilation may be somewhat higher than the limit. In practice the limit works reasonably well, though.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16220/head:pull/16220
$ git checkout pull/16220
Update a local copy of the PR:
$ git checkout pull/16220
$ git pull https://git.openjdk.org/jdk.git pull/16220/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16220
View PR using the GUI difftool:
$ git pr show -t 16220
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16220.diff
Webrev
Link to Webrev Comment