Skip to content

8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM #19340

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

Closed
wants to merge 2 commits into from

Conversation

jaikiran
Copy link
Member

@jaikiran jaikiran commented May 22, 2024

Can I please get a review of this test-only change for addressing https://bugs.openjdk.org/browse/JDK-8332490?

The jmh test opens a InflaterInputStream, reads the stream contents, but then doesn't close the stream. This can lead to resource leak which can then cause OOM as noted in that JBS issue.

The commit in this PR closes the InflaterInputStream when the reads complete.

make test TEST=micro:org.openjdk.bench.java.util.zip.InflaterInputStreams

and

./build/macosx-aarch64/images/jdk/bin/java -jar ./build/macosx-aarch64/images/test/micro/benchmarks.jar org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead -t max -f 1 -wi 2 -foe true

pass after this change.


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-8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19340/head:pull/19340
$ git checkout pull/19340

Update a local copy of the PR:
$ git checkout pull/19340
$ git pull https://git.openjdk.org/jdk.git pull/19340/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19340

View PR using the GUI difftool:
$ git pr show -t 19340

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19340.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 22, 2024

👋 Welcome back jpai! 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.

@openjdk
Copy link

openjdk bot commented May 22, 2024

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

8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM

Reviewed-by: aturbanov, redestad

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 15 new commits pushed to the master branch:

  • 3d4185a: 8332739: Problemlist compiler/codecache/CheckLargePages until JDK-8332654 is fixed
  • c4557a7: 8332463: Byte conditional pattern case element dominates short constant case element
  • d59c12f: 8329718: Incorrect @since tags in elements in jdk.compiler and java.compiler
  • b4d1454: 8332740: [BACKOUT] JDK-8331081 'internal proprietary API' diagnostics if --system is configured to an earlier JDK version
  • 37c4778: 8332096: hotspot-ide-project fails with this-escape
  • 2170e99: 8331081: 'internal proprietary API' diagnostics if --system is configured to an earlier JDK version
  • a0c5714: 8332071: Convert package.html files in java.management.rmi to package-info.java
  • afed7d0: 8329538: Accelerate P256 on x86_64 using Montgomery intrinsic
  • 9ca90cc: 8332610: Remove unused nWakeups in ObjectMonitor
  • 92d3350: 8331920: ubsan: g1CardSetContainers.inline.hpp:266:5: runtime error: index 2 out of bounds for type 'G1CardSetHowl::ContainerPtr [2]' reported
  • ... and 5 more: https://git.openjdk.org/jdk/compare/5f804b2ec12627b593353ceeab881187b0bb5cd6...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label May 22, 2024
@openjdk
Copy link

openjdk bot commented May 22, 2024

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

  • core-libs

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 core-libs core-libs-dev@openjdk.org label May 22, 2024
@mlbridge
Copy link

mlbridge bot commented May 22, 2024

Webrevs

while (iis.read(inflated, 0, inflated.length) != -1);
try (InflaterInputStream iis = new InflaterInputStream(deflated)) {
while (iis.read(inflated, 0, inflated.length) != -1);
}
Copy link
Contributor

@AlanBateman AlanBateman May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably this only works because closing the underlying stream (a BAIS in this case) is a no-op.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the underlying BAIS can be repeatedly closed without affecting the benchmark.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Alan, before this change, the memory gets occupied by too many of these:

   1:      10871820      521847360  jdk.internal.ref.CleanerImpl$PhantomCleanableRef (java.base@23-internal)
   2:      10871758      260922192  java.util.zip.Inflater$InflaterZStreamRef (java.base@23-internal)

Closing the InflaterInputStream releases those underlying InflaterZStreamRefs.

Copy link
Member

@cl4es cl4es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - feel free to add a comment that closing the InflaterInputStream has no effect on the underlying stream deflated.

while (iis.read(inflated, 0, inflated.length) != -1);
try (InflaterInputStream iis = new InflaterInputStream(deflated)) {
while (iis.read(inflated, 0, inflated.length) != -1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the underlying BAIS can be repeatedly closed without affecting the benchmark.

@jaikiran
Copy link
Member Author

LGTM - feel free to add a comment that closing the InflaterInputStream has no effect on the underlying stream deflated.

Hello Claes, I've updated the PR to include a comment.

Copy link
Member

@cl4es cl4es left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, thought I had already approved. Comment is fine.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 22, 2024
@jaikiran
Copy link
Member Author

Thank you Alan and Claes for the reviews.

@jaikiran
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented May 23, 2024

Going to push as commit 98f6a80.
Since your change was applied there have been 15 commits pushed to the master branch:

  • 3d4185a: 8332739: Problemlist compiler/codecache/CheckLargePages until JDK-8332654 is fixed
  • c4557a7: 8332463: Byte conditional pattern case element dominates short constant case element
  • d59c12f: 8329718: Incorrect @since tags in elements in jdk.compiler and java.compiler
  • b4d1454: 8332740: [BACKOUT] JDK-8331081 'internal proprietary API' diagnostics if --system is configured to an earlier JDK version
  • 37c4778: 8332096: hotspot-ide-project fails with this-escape
  • 2170e99: 8331081: 'internal proprietary API' diagnostics if --system is configured to an earlier JDK version
  • a0c5714: 8332071: Convert package.html files in java.management.rmi to package-info.java
  • afed7d0: 8329538: Accelerate P256 on x86_64 using Montgomery intrinsic
  • 9ca90cc: 8332610: Remove unused nWakeups in ObjectMonitor
  • 92d3350: 8331920: ubsan: g1CardSetContainers.inline.hpp:266:5: runtime error: index 2 out of bounds for type 'G1CardSetHowl::ContainerPtr [2]' reported
  • ... and 5 more: https://git.openjdk.org/jdk/compare/5f804b2ec12627b593353ceeab881187b0bb5cd6...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 23, 2024
@openjdk openjdk bot closed this May 23, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 23, 2024
@openjdk
Copy link

openjdk bot commented May 23, 2024

@jaikiran Pushed as commit 98f6a80.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jaikiran jaikiran deleted the 8332490 branch November 8, 2024 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants