RFR: 8319650: Improve heap dump performance with class metadata caching

Aleksey Shipilev shade at openjdk.org
Tue Nov 7 19:36:21 UTC 2023


See the rationale and some profiles in the bug.

This PR implements simple caching for object instance dumping, which is overwhelmingly hottest path in heap dumping code. This allows to put the cache straight in `HeapObjectDumper`, which is effectively thread local. A simple hash table would then work to cache the class metadata.

Given a simple workload from the bug, these are the motivational improvements and historical perspective:


$ for I in `seq 1 3`; do java -XX:+UseParallelGC -XX:+HeapDumpAfterFullGC -Xms8g -Xmx8g HeapDump.java 2>&1 | grep created; rm *.hprof; done

# Baseline JDK 8u382
Heap dump file created [1440865228 bytes in 5.492 secs]
Heap dump file created [1440865228 bytes in 5.460 secs]
Heap dump file created [1440865228 bytes in 5.471 secs]

# Baseline JDK 11.0.21
Heap dump file created [1446043070 bytes in 5.088 secs]
Heap dump file created [1446042039 bytes in 5.096 secs]
Heap dump file created [1446042835 bytes in 5.081 secs]

# Baseline JDK 17.0.10
Heap dump file created [1446841531 bytes in 3.276 secs]
Heap dump file created [1446841673 bytes in 3.342 secs]
Heap dump file created [1446841590 bytes in 3.323 secs]

# Baseline JDK 21.0.2 EA
Heap dump file created [1447828697 bytes in 5.516 secs]
Heap dump file created [1447829756 bytes in 5.461 secs]
Heap dump file created [1447829539 bytes in 5.435 secs]

# Baseline JDK 22
Heap dump file created [1447285149 bytes in 5.232 secs]
Heap dump file created [1447285149 bytes in 5.211 secs]
Heap dump file created [1447284813 bytes in 5.222 secs]

# Patched JDK 22
Heap dump file created [1447285087 bytes in 1.071 secs]
Heap dump file created [1447285149 bytes in 1.073 secs]
Heap dump file created [1447285073 bytes in 1.058 secs]


This amounts to 5x improvement, 1.2 GB/sec dump rate (somewhat I/O limited), and the best heap dump performance across all JDK releases. I am planning to backport this patch where possible: at least to JDK 21u, but hopefully to JDK 17u as well.

There are other simple improvements, but this one is the top bottleneck.

-------------

Commit messages:
 - Fix

Changes: https://git.openjdk.org/jdk/pull/16545/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16545&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8319650
  Stats: 120 lines in 1 file changed: 96 ins; 5 del; 19 mod
  Patch: https://git.openjdk.org/jdk/pull/16545.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16545/head:pull/16545

PR: https://git.openjdk.org/jdk/pull/16545


More information about the hotspot-runtime-dev mailing list