-
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
8289764: gc/lock tests failed with "OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects" #9658
Conversation
👋 Welcome back rsunderbabu! A progress list of the required criteria for merging this PR into |
…: failed reallocation of scalar replaced objects"
@rsunderbabu 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. |
Summary of changes
|
Webrevs
|
|
||
public Worker() { | ||
locker.enable(); | ||
} | ||
|
||
public void run() { | ||
locker.lock(); | ||
GarbageUtils.eatMemory(getExecutionController(), garbageProducer); | ||
WhiteBox.getWhiteBox().fullGC(); |
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 add some more work for GC here: add and free objects, arrays, strings and free them. Then call WB.GC to ensure that GC is triggered.
You could add the corresponding method in GarbageUtils and always use it instead eatMemory.
Might be call WB.YoungGC while generating garbage to put something into old gen as well as in young gen
…: failed reallocation of scalar replaced objects"
Tested for all GC types - G1GC, SerialGC, ParallelGC, ZGC. |
final long memChunk = testMemory / YOUNG_GC_ITERATIONS; | ||
int iteration = 0; | ||
|
||
while (stresser.continueExecution()) { |
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 loop never completes, while the goal is to produce some garbage and trigger GC.
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.
stresser runs for the duration of the test, I believe. Loop completes when test duration is complete.
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.
ough, yes, I mean that loop was completed only once, so we have only one iteration per test, while the goal is to run a lot of lock/GC/unlock iterations.
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.
Loop won't run for just once. It will run for the duration of the test. If the test is configured to run, say, 2 mins, stresser.continueExecution() will be false after 2 mins.
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.
exactly, however, the whole 'engageGC' method will be executed only once and always work in this loop.
So the combination of lock/engageGC()/unlock is executed only once and the test spends all it's time in 'engageGC' which is not the stress for lock/unlock and moreover could cause OOME if lock/unlock really locks GC.
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.
so this is the algorithm you are getting at?
while( test.duration ) {
lock
engageGC (100 youngGC and 1 fullGC)
unlock
}
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.
Yes. It is what test should do.
|
||
while (stresser.continueExecution()) { | ||
while (iteration++ < YOUNG_GC_ITERATIONS) { | ||
byteArrayProducer.create(memChunk); |
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 is needed to create at least some old objects which live after young GC.
I propose to add 'tmp = byteArrayProducer.create(memChunk);' and free this tmp variable tight before WB.fullGC().
So we will have objects with different age (up to to 100).
…: failed reallocation of scalar replaced objects"
…: failed reallocation of scalar replaced objects"
iteration = 0; | ||
WhiteBox.getWhiteBox().fullGC(); | ||
while (++iteration < YOUNG_GC_ITERATIONS) { | ||
byteArrayProducer.create(memChunk); |
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 add these object to array like initialAlloc to have objects of various ages in different heap gens
locker.unlock(); | ||
ExecutionController stresser = getExecutionController(); | ||
// Use only 30% of the heap. | ||
final long testMemory = 3 * Runtime.getRuntime().maxMemory() / 10; |
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.
might be better to rename to testMemorySize
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 prefer to leave it as engageGC, it shows the intent better.
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 meant rename testMemory to testMemorySize
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.
Oh! I misunderstood. Will submit changes.
@rsunderbabu 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 425 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 (@lmesnik) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@rsunderbabu |
…: failed reallocation of scalar replaced objects"
/sponsor |
@lmesnik The PR has been updated since the change author (@rsunderbabu) issued the |
/integrate |
@rsunderbabu |
/sponsor |
Going to push as commit 7b81a9c.
Your commit was automatically rebased without conflicts. |
@lmesnik @rsunderbabu Pushed as commit 7b81a9c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Tested with all GC options
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9658/head:pull/9658
$ git checkout pull/9658
Update a local copy of the PR:
$ git checkout pull/9658
$ git pull https://git.openjdk.org/jdk pull/9658/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 9658
View PR using the GUI difftool:
$ git pr show -t 9658
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9658.diff