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

8260337: Optimize ImageReader lookup, used by Class.getResource #2212

Closed
wants to merge 10 commits into from

Conversation

cl4es
Copy link
Member

@cl4es cl4es commented Jan 25, 2021

This patch optimizes the code paths exercised by String.class.getResource("String.class") by:

  • Adding an ASCII fast-path to methods verifying strings in the jimage, which can then be done allocation-free
  • Avoiding the allocation of the long[8] attributes when verifying only for the purpose of verifying a path exists
  • Using the JNUA.create fast-path in SystemModuleReader (which should be OK since we just verified the given name is a JRT path)
  • Remove a redundant check in Class::resolveName and fitting the StringBuilder to size

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8260337: Optimize ImageReader lookup, used by Class.getResource

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2212/head:pull/2212
$ git checkout pull/2212

Sorry, something went wrong.

cl4es added 5 commits January 22, 2021 16:04

Verified

This commit was signed with the committer’s verified signature.
mfridman Michael Fridman
…SystemModuleReader, improve Class.resolveName
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 25, 2021

👋 Welcome back redestad! 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 Jan 25, 2021

@cl4es 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 Jan 25, 2021
@cl4es
Copy link
Member Author

cl4es commented Jan 25, 2021

On the provided benchmark we can observe a 2x speed-up and a 70% reduction in allocation.

Baseline:

Benchmark                                                      Mode  Cnt     Score     Error   Units
ClassGetResource.stringClass                                   avgt    5  2885.403 ± 309.787   ns/op
ClassGetResource.stringClass:·gc.alloc.rate.norm               avgt    5  1368.124 ±   0.056    B/op

Patch:

Benchmark                                                      Mode  Cnt     Score     Error   Units
ClassGetResource.stringClass                                   avgt    5  1411.980 ± 155.877   ns/op
ClassGetResource.stringClass:·gc.alloc.rate.norm               avgt    5   408.038 ±   0.043    B/op

@cl4es cl4es changed the title 8260337: Optimize Class.getResource lookups of system module resources 8260337: Optimize ImageReader lookup, used by Class.getResource Jan 25, 2021
@cl4es cl4es marked this pull request as ready for review January 25, 2021 15:26
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 25, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 25, 2021

Webrevs

Copy link
Member

@JimLaskey JimLaskey left a comment

Choose a reason for hiding this comment

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

Nice clean up. LGTM

@openjdk
Copy link

openjdk bot commented Jan 27, 2021

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

8260337: Optimize ImageReader lookup, used by Class.getResource

Reviewed-by: jlaskey, sundar

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

  • 906faca: 8260372: [PPC64] Add support for JDK-8210498 and JDK-8222841
  • b38d5be: 8261340: Fix 'deprecated' warnings in the vmTestbase/nsk tests
  • b0e7e5a: 8261263: Simplify javadoc link code
  • 8ebed28: 8261237: remove isClassPathAttributePresent method
  • 5183d8a: 8260355: AArch64: deoptimization stub should save vector registers
  • 5d8204b: 8261368: The new TestNullSetColor test is placed in the wrong group
  • f03e839: 8261127: Cleanup THREAD/TRAPS/CHECK usage in CDS code
  • 7451962: 8129776: The optimized Stream returned from Files.lines should unmap the mapped byte buffer (if created) when closed
  • ad525bc: 8261281: Linking jdk.jpackage fails for linux aarch32 builds after 8254702
  • 2fd8ed0: 8240632: Note differences between IEEE 754-2019 math lib special cases and java.lang.Math
  • ... and 226 more: https://git.openjdk.java.net/jdk/compare/535c2927b6e0004ffa1ab5af3e19a622ab14d9f1...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 ready Pull request is ready to be integrated label Jan 27, 2021
@AlanBateman
Copy link
Contributor

@JimLaskey Do you have anything that documents the jimage format that could be checked into the repo to help with future changes in this change? Clearly any such document would need a warning in 96pt font that the format is JDK internal, submit to change from build to build, etc. but it could be helpful when working on this code.

@mlbridge
Copy link

mlbridge bot commented Jan 31, 2021

Mailing list message from Jim Laskey on core-libs-dev:

I?ve been handing out the original jimage docs on request. Surprisingly, it?s still accurate. Will dig up on Monday to post.

??

@mlbridge
Copy link

mlbridge bot commented Feb 2, 2021

Mailing list message from Jim Laskey on core-libs-dev:

Here is the original document (it's available in the jigsaw wiki)

How would you like it flushed out?

Cheers,

-- Jim

On Jan 31, 2021, at 11:40 AM, Jim Laskey <james.laskey at oracle.com> wrote:

I?ve been handing out the original jimage docs on request. Surprisingly, it?s still accurate. Will dig up on Monday to post.

??

@cl4es
Copy link
Member Author

cl4es commented Feb 7, 2021

@sundararajana @AlanBateman - can I solicit a second review on this? Or an OK from Alan to go ahead and push with the one review.

Copy link
Member

@sundararajana sundararajana left a comment

Choose a reason for hiding this comment

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

LGTM

@cl4es
Copy link
Member Author

cl4es commented Feb 9, 2021

@JimLaskey @sundararajana - thanks for reviewing!

/integrate

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

openjdk bot commented Feb 9, 2021

@cl4es Since your change was applied there have been 237 commits pushed to the master branch:

  • f0bd9db: 8257569: Failure observed with JfrVirtualMemory::initialize
  • 906faca: 8260372: [PPC64] Add support for JDK-8210498 and JDK-8222841
  • b38d5be: 8261340: Fix 'deprecated' warnings in the vmTestbase/nsk tests
  • b0e7e5a: 8261263: Simplify javadoc link code
  • 8ebed28: 8261237: remove isClassPathAttributePresent method
  • 5183d8a: 8260355: AArch64: deoptimization stub should save vector registers
  • 5d8204b: 8261368: The new TestNullSetColor test is placed in the wrong group
  • f03e839: 8261127: Cleanup THREAD/TRAPS/CHECK usage in CDS code
  • 7451962: 8129776: The optimized Stream returned from Files.lines should unmap the mapped byte buffer (if created) when closed
  • ad525bc: 8261281: Linking jdk.jpackage fails for linux aarch32 builds after 8254702
  • ... and 227 more: https://git.openjdk.java.net/jdk/compare/535c2927b6e0004ffa1ab5af3e19a622ab14d9f1...master

Your commit was automatically rebased without conflicts.

Pushed as commit 2f893c2.

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

None yet

4 participants