JDK-8319955 : Improve dependencies removal during class unloading
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-13
  • Updated: 2024-04-19
  • Resolved: 2023-11-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 22
21.0.4-oracleFixed 22 b24Fixed
Related Reports
Relates :  
Description
During class unloading, removing the dependencies (calls to DependencyContext::remove_all_dependencies) is very slow.

In a class unloading stress test, the total time spent in that call is like:

[537,573s][gc               ] GC(106) do_unloading: loaders processed 279, loaders removed 6001
[537,573s][gc               ] GC(106) Unloading took 45,54, depunload took 38,41 percent 84,33

I.e. dependency unloading ("depunload") took 38,41ms out of  45,54ms.

The reason is that for every dependency the code performs a cmpxchg to add that dependency into the purge list. The cmpxchg is expensive.

Batching the cmpxchg on a per instanceKlass basis decreases the time to one seventh:

[666,449s][gc               ] GC(139) do_unloading: loaders processed 280, loaders removed 6001
[666,449s][gc               ] GC(139) Unloading took 12,00, depunload took 5,47 percent 45,58

i.e. 5,47ms.
Comments
Fix request [21u] I backport this for parity with 21.0.4-oracle. Medium risk. Local change to central component. Well hung. Clean backport. SAP nightly testing passed.
06-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/456 Date: 2024-04-05 07:59:50 +0000
05-04-2024

Changeset: fbe19378 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2023-11-15 08:33:44 +0000 URL: https://git.openjdk.org/jdk/commit/fbe19378c38decaff221f6570d1b78bb801a5e5d
15-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16639 Date: 2023-11-13 18:52:47 +0000
13-11-2023