JDK-8317007 : Add bulk removal of dead nmethods during class unloading
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-09-27
  • Updated: 2024-05-07
  • Resolved: 2023-12-18
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 23
21.0.4-oracleFixed 23 b03Fixed
Related Reports
Blocks :  
Blocks :  
Blocks :  
Relates :  
Description
Currently during class unloading dead nmethods are removed one by one as the nmethods are unloaded.
Since this unregistering is serial, it would be nice to have this operation done in parallel and in bulk to improve pause time performance.
Comments
Fix request [21u] I backport this for parity with 21.0.4-oracle. Medium risk, a larger change in a central component. But well hung and no follow-up bugs. We should backport it nevertheless to close the class unloading performance gap as OracleJDK does. Clean backport. SAP nighlty testing passed.
06-05-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/548 Date: 2024-05-02 11:29:12 +0000
02-05-2024

Changeset: f5538195 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2023-12-18 08:44:43 +0000 URL: https://git.openjdk.org/jdk/commit/f55381950266088cc0284754b16663675867ac87
18-12-2023

Added two graphs showing Remark pause time before/after the change, and a breakdown of Remark Pause time showing Purge Unlinked NMethods and the new Unregister NMethod phases, with the ccstress test from JDK-8315503.
07-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16767 Date: 2023-11-21 16:14:42 +0000
21-11-2023

Implementing for the STW collectors: this is not trivial for the concurrent collectors because the change would need to modify the time the CodeCache_lock would need to be held. I.e. the code would need to change from: for (all nmethods) { lock CodeCache_lock ... unregister_nmethod ... unlock CodeCache_lock } to lock CodeCache_lock for (all nmethods) { ... } bulk unregister nmethods unlock CodeCache_lock which is different wrt to concurrent mutator/compiler activity.
14-11-2023

Also, for parallel gc, no parallelization attempt is made: the "scavengable nmethods" is a long linked list currently which is not amenable to parallelization. This needs extra work anyway. Still, doing the bulk operation, i.e. not going through the LL for every element to unregister but only once during class unloading should be much faster than before.
14-11-2023

A reproducer showing fairly long Remark pauses is attached to JDK-8315503.
29-09-2023