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

8295673: Deprecate and disable legacy parallel class loading workaround for non-parallel-capable class loaders #10832

Closed
wants to merge 3 commits into from

Conversation

coleenp
Copy link
Contributor

@coleenp coleenp commented Oct 24, 2022

This change adds an option EnableWaitForParallelLoad to enable the legacy behavior where the VM will manage synchronization for multiple threads loading the same class using a non-parallel capable class loader that have released the class loader lock. The VM will break the class loader lock for parallel threads trying to load the class, and wait for the first thread that initiated loading the class to complete. The subsequent threads will use the result of the first thread, rather than get a LinkageError: duplicate class definition for loading the class without synchronization.
Releasing the class loader lock was a common workaround for class loaders that used a non-hierarchical delegation scheme to avoid deadlock, before parallel capable class loading was added.
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ClassLoader.html#registerAsParallelCapable()

Tested with tier1-6 and internal applications.


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
  • Change requires a CSR request to be approved

Issues

  • JDK-8295673: Deprecate and disable legacy parallel class loading workaround for non-parallel-capable class loaders
  • JDK-8295848: Deprecate legacy parallel class loading workaround for non-parallel-capable class loaders (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10832

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 24, 2022

👋 Welcome back coleenp! 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 Oct 24, 2022

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

  • hotspot-runtime

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-runtime hotspot-runtime-dev@openjdk.org label Oct 24, 2022
@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Oct 24, 2022
@coleenp coleenp changed the title 8295673: Deprecate JVM class loading double_lock_wait handling 8295673: Deprecate legacy parallel class loading workaround for non-parallel-capable class loaders Oct 26, 2022
@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Nov 3, 2022
@coleenp coleenp marked this pull request as ready for review November 3, 2022 12:45
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 3, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 3, 2022

Webrevs

@mlchung
Copy link
Member

mlchung commented Nov 3, 2022

/label add core-libs

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Nov 3, 2022
@openjdk
Copy link

openjdk bot commented Nov 3, 2022

@mlchung
The core-libs label was successfully added.

@mlchung
Copy link
Member

mlchung commented Nov 3, 2022

Adding core-libs-dev so that more developers know this behavioral change.

Background:

Prior to JDK 7, custom class loaders using non-hierarchical class delegation model were prone to deadlock (see [1] for details). This workaround was added in the VM in JDK 6 to allow parallel class loading for non-parallel-capable class loaders to avoid deadlocks. The VM also supports a common workaround at the time that some customers explicitly issue a wait() on the class loader lock.

Such workaround was kept to allow those customers to migrate to using multi-thread-safe parallel-capable class loaders. It has been 11 years since Java 7 and it's expected that those deadlock-prone custom class loaders should have migrated to the parallel-capable class loaders.

If customers have class loaders depending on this legacy behavior, they can set -XX:+EnableWaitForParallelLoad flag to enable the legacy behavior and migrate to parallel-capable class loaders as soon as possible. The EnableWaitForParallelLoad VM flag will be removed in a future release.

Refers to CSR JDK-8295848 for details.

@openjdk
Copy link

openjdk bot commented Nov 3, 2022

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

8295673: Deprecate and disable legacy parallel class loading workaround for non-parallel-capable class loaders

Reviewed-by: mchung, dholmes

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

  • 8836b92: 8296226: Add constructors (String,Throwable) and (Throwable) to InvalidParameterException
  • 51f8e9b: 8296443: NMT: Remove cmdline_tracking_level handling code
  • 087cedc: 8295261: RISC-V: Support ReductionV instructions for Vector API
  • 556377a: 8296270: Memory leak in ClassLoader::setup_bootstrap_search_path_impl
  • c2f7638: 8296335: Fix accessibility manual test instruction
  • 91292d5: 8286301: Port JEP 425 to RISC-V
  • 581133a: 8294696: BufferedInputStream.transferTo should drain buffer when mark set
  • d8573b2: 8294488: Delete KCMS transforms wrappers
  • f857f79: 8015739: Background of JInternalFrame is located out of JInternalFrame
  • b847fb6: 8296414: [BACKOUT] JDK-8295319: pending_cards_at_gc_start doesn't include cards in thread buffers
  • ... and 31 more: https://git.openjdk.org/jdk/compare/d771abb2fbc72e02faf02f0724aea301953ac5e8...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 Nov 3, 2022
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

It would be a little clearer if the bug synopsis was "Deprecate and disable legacy ...".

A couple of queries below, but otherwise this looks good - and it will be good to see this old workaround disappear.

Thanks.

src/hotspot/share/classfile/placeholders.cpp Outdated Show resolved Hide resolved
@coleenp coleenp changed the title 8295673: Deprecate legacy parallel class loading workaround for non-parallel-capable class loaders 8295673: Deprecate and disable legacy parallel class loading workaround for non-parallel-capable class loaders Nov 6, 2022
@openjdk-notifier
Copy link

@coleenp Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks.

@coleenp
Copy link
Contributor Author

coleenp commented Nov 7, 2022

Thank you for the discussions, CSR, help and code reviews, @mlchung and @dholmes-ora .
/integrate

@openjdk
Copy link

openjdk bot commented Nov 7, 2022

Going to push as commit 76790ad.
Since your change was applied there have been 52 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 Nov 7, 2022
@openjdk openjdk bot closed this Nov 7, 2022
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 7, 2022
@openjdk openjdk bot removed the rfr Pull request is ready for review label Nov 7, 2022
@openjdk
Copy link

openjdk bot commented Nov 7, 2022

@coleenp Pushed as commit 76790ad.

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

@coleenp coleenp deleted the remove-double-lock branch November 7, 2022 23:32
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 hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants