Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

rsunderbabu
Copy link
Contributor

@rsunderbabu rsunderbabu commented Jul 27, 2022

Tested with all GC options


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8289764: gc/lock tests failed with "OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects"

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 27, 2022

👋 Welcome back rsunderbabu! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

…: failed reallocation of scalar replaced objects"
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 27, 2022
@openjdk
Copy link

openjdk bot commented Jul 27, 2022

@rsunderbabu The following label will be automatically applied to this pull request:

  • hotspot

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.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Jul 27, 2022
@rsunderbabu
Copy link
Contributor Author

Summary of changes

  1. Remove explicit creation of garbage, instead call GC directly.
  2. Retain the class of functions being tested - jni, jniref, jvmti, malloc.
  3. Only one test is retained for every class of function.

@mlbridge
Copy link

mlbridge bot commented Jul 27, 2022

Webrevs


public Worker() {
locker.enable();
}

public void run() {
locker.lock();
GarbageUtils.eatMemory(getExecutionController(), garbageProducer);
WhiteBox.getWhiteBox().fullGC();
Copy link
Member

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"
@rsunderbabu
Copy link
Contributor Author

Tested for all GC types - G1GC, SerialGC, ParallelGC, ZGC.

final long memChunk = testMemory / YOUNG_GC_ITERATIONS;
int iteration = 0;

while (stresser.continueExecution()) {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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
}

Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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;
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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.

@openjdk
Copy link

openjdk bot commented Aug 9, 2022

@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:

8289764: gc/lock tests failed with "OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects"

Reviewed-by: lmesnik

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 master branch:

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 in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 9, 2022
@rsunderbabu
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 10, 2022
@openjdk
Copy link

openjdk bot commented Aug 10, 2022

@rsunderbabu
Your change (at version 0c6c867) is now ready to be sponsored by a Committer.

@openjdk openjdk bot removed the sponsor Pull request is ready to be sponsored label Aug 10, 2022
…: failed reallocation of scalar replaced objects"
@lmesnik
Copy link
Member

lmesnik commented Aug 24, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 24, 2022

@lmesnik The PR has been updated since the change author (@rsunderbabu) issued the integrate command - the author must perform this command again.

@rsunderbabu
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 25, 2022
@openjdk
Copy link

openjdk bot commented Aug 25, 2022

@rsunderbabu
Your change (at version f9b0c37) is now ready to be sponsored by a Committer.

@lmesnik
Copy link
Member

lmesnik commented Aug 25, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 25, 2022

Going to push as commit 7b81a9c.
Since your change was applied there have been 425 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 25, 2022
@openjdk openjdk bot closed this Aug 25, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Aug 25, 2022
@openjdk
Copy link

openjdk bot commented Aug 25, 2022

@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.

@rsunderbabu rsunderbabu deleted the 8289764 branch October 16, 2022 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

2 participants