JDK-8319650 : Improve heap dump performance with class metadata caching
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 17,21,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-07
  • Updated: 2024-04-09
  • Resolved: 2023-11-13
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.4Fixed 22 b24Fixed
Related Reports
Relates :  
Description
Heap dumping performance is something our users frequently complain about. Modern JDKs already implement parallel heap dumps from diagnostic commands, which is nice. But there are single-threaded improvements that we can easily do.

If you profile current heap dumping code, then you would see that walking the class data looking for fields takes the overwhelming majority of execution time. It got much worse in JDK 21 with JDK-8292818, where looking for field data involves re-parsing the class metadata stream all the time. See `jdk21-heapdump-png` for sample profile for sample reproducer (`HeapDump.java`) on JDK 21.

Since heap dumping code runs sporadically, we can cache some class metadata that heap dumping code needs on hot paths.
Comments
[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Unclean backport to improve heap dump performance. Tests pass. Original 21u RFR acked by Paul Hohensee. In mainline since Nov 2023 without a bug tail. The risk is in regressing the frequently used diagnostic subsystem, but that should be considered against the major improvement in performance.
07-03-2024

Removed jdk21u-fix-yes to get attention of current JDK 21u maintainers, whose approval is needed now.
07-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/8 Date: 2023-12-13 10:46:42 +0000
13-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/388 Date: 2023-11-21 12:28:53 +0000
22-11-2023

Changeset: 03db8281 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2023-11-13 11:51:38 +0000 URL: https://git.openjdk.org/jdk/commit/03db82818b905f21cb5ad1d56a687e238b4a6e33
13-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16545 Date: 2023-11-07 18:37:59 +0000
07-11-2023