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

8295153: java/util/Base64/TestEncodingDecodingLength.java ran out of memory #19036

Conversation

justin-curtis-lu
Copy link
Member

@justin-curtis-lu justin-curtis-lu commented May 1, 2024

Please review this PR which converts TestEncodingDecodingLength.java into a whitebox test which allows for testing to be done without memory usage issues.

Currently, the test requires about ~2.75 Integer.MAX_VALUE sized byte arrays worth of memory. (2 for the initial array allocation, .75 for the target array in decode()). While the -Xms6g -Xmx8g options should address this, there have been intermittent memory issues, as the underlying machine machine may be running other tests simultaneously.

By converting this test to a white-box test not only does it get rid of memory issues, but it also gets rid of the need to decode 2GB of data 3 times. The change is done using reflection to test the private visibility methods encodedOutLength and decodedOutLength, which the public encode and decode overloaded methods call respectively.


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-8295153: java/util/Base64/TestEncodingDecodingLength.java ran out of memory (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19036

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 1, 2024

👋 Welcome back jlu! 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 1, 2024

@justin-curtis-lu 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:

8295153: java/util/Base64/TestEncodingDecodingLength.java ran out of memory

Reviewed-by: lancea, naoto

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

  • 0a24dae: 8322043: HeapDumper should use parallel dump by default
  • 62d5d1e: 8319598: SMFParser misinterprets interrupted running status
  • 2a95cd4: 8331495: Limit BasicDirectoryModel/LoaderThreadCount.java to Windows only
  • e833bfc: 8331222: Malformed text in the jpackage doc page
  • 4f529f8: 8331427: Rename confusingly named ArraysSupport.signedHashCode
  • 44dc850: 8331212: Error recovery for broken switch expressions could be improved
  • b2fb5ea: 8331142: Add test for number of loader threads in BasicDirectoryModel
  • 663acd2: 8330969: scalability issue with loaded JVMTI agent
  • f215899: 8331393: AArch64: u32 _partial_subtype_ctr loaded/stored as 64

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

➡️ 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 1, 2024
@openjdk
Copy link

openjdk bot commented May 1, 2024

@justin-curtis-lu 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 1, 2024
@mlbridge
Copy link

mlbridge bot commented May 1, 2024

Webrevs

Copy link
Contributor

@LanceAndersen LanceAndersen left a comment

Choose a reason for hiding this comment

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

Thank you for taking this on Justin and converting to a junit test as part of your updates.

Overall it looks good on an initial pass.

Please see a few suggestions for your consideration

int size = Integer.MAX_VALUE - 8;
byte[] inputBytes = new byte[size];
byte[] outputBytes = new byte[size];
private static final int size = Integer.MAX_VALUE - 8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps consider size-> SIZE and maybe tweak the name and add an additional comment to its purpose

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review Lance, both comments should be addressed in aa25c9a


private static final void checkOOM(String methodName, Runnable r) {
// OOME case
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps make this a separate test case so that the IAE test fails the OOME still runs

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 1, 2024
m.invoke(ENCODER, LARGE_MEM_SIZE, true);
} catch (InvocationTargetException ex) {
Throwable rootEx = ex.getCause();
assertEquals(OutOfMemoryError.class, rootEx.getClass(), "00ME should be thrown");
Copy link
Member

Choose a reason for hiding this comment

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

Sorry if it is intentional, but I wonder if you meant "OOME" instead of "00ME" here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, you sometimes see what you want to see

Copy link
Member Author

Choose a reason for hiding this comment

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

That was unexpected, wonder how I did that unconsciously...

*/
m.invoke(DECODER, src, -LARGE_MEM_SIZE + 1, 1);
} catch (InvocationTargetException ex) {
fail("Decode should neither throw NASE or OOME: " + ex.getCause());
Copy link
Member

Choose a reason for hiding this comment

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

Should we check the cause is either NASE or OOME here?

Copy link
Contributor

Choose a reason for hiding this comment

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

The original test just validated there was no exception thrown, so I think we can just update the message to indicate an unexpected Exception.

I had added this as a comment but must have missed hitting the comment button

Copy link
Member Author

Choose a reason for hiding this comment

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

Improved the error message to be more general, (as no exception should be thrown). Comments clarify that the method used to throw NASE and OOME.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

LGTM

@justin-curtis-lu
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented May 3, 2024

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

  • cf2c80e: 8331582: Incorrect default Console provider comment
  • 77b7122: 8312104: Update java man pages to include new security category in -XshowSettings
  • 87bb66c: 8331569: G1: Rename G1HRPrinter to G1HeapRegionPrinter
  • 37c2469: 8331633: Use MIN2 in bound_minus_alignment
  • 1d083eb: 8331562: G1: Remove API to force allocation of new regions
  • 9697bc3: 8331428: ubsan: JVM flag checking complains about MaxTenuringThresholdConstraintFunc, InitialTenuringThresholdConstraintFunc and AllocatePrefetchStepSizeConstraintFunc
  • ce73fec: 8331048: G1: Prune rebuild candidates based on G1HeapWastePercent early
  • 58ef9e4: 8331402: G1: Remove is_active() calls in G1HRPrinter logging
  • 3c77dad: 8331507: JFR: Improve example usage in -XX:StartFlightRecording:help
  • 8ed3190: 8331401: G1: Make G1HRPrinter AllStatic
  • ... and 53 more: https://git.openjdk.org/jdk/compare/b96b38c2c9a310d5fe49b2eda3e113a71223c7d1...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 3, 2024

@justin-curtis-lu Pushed as commit b33096f.

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

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.

3 participants