RFR: 8353559: Restructure CollectedHeap error printing
Albert Mingkun Yang
ayang at openjdk.org
Thu Apr 3 11:32:55 UTC 2025
On Wed, 2 Apr 2025 18:09:12 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:
> Calling Universe::heap()->print_on_error() gets dispatched to the most specific implementation, which for some GCs is their own implementation instead of the default in CollectedHeap. Each GC-specific implementation calls back to CollectedHeap::print_on_error(), which then dispatches back into the specific implementation of print_on(). This is kind of awkward and creates a call-chain that's not straightforward to wrap your head around, jumping back and forth via CollectedHeap and the specific implementation.
>
> To make the call-chain cleaner, I have made print_on_error() a pure virtual method in CollectedHeap, and implemented print_on_error() in each GC's implementation of CollectedHeap. In addition, I have removed print_extended_on() from CollectedHeap and implemented that for the GCs that actually need/use it.
>
> Removing the usage of the common print_on_error() also means that GCs that do not print anything interesting for their barrier set can omit this. So, I've removed it from ZGC and Shenandoah.
>
> To make print_on_error() consistent with print_on(), I have moved the printing of "Heap:" to the caller(s) of print_on_error() (only inside vmError.cpp). This is a trivial change for all GCs except ZGC, which requires some restructuring in its error printing.
>
> The old and new printing orders are shown below for ZGC:
>
> # Old
> <precious log>
> <zgc globals>
> <heap>
> <zgc page table>
> <barrier set>
> <polling page>
>
>
>
> # New
> <precious log>
> <heap>
> <zgc globals>
> <zgc page table>
> <polling page>
>
>
> Testing:
> * GHA
> * Tiers 1 & 2
> * Manually verified that printing still works and outputs the intended information via running the following commands and comparing the output.
>
> ../fastdebug-old/jdk/bin/java -XX:ErrorHandlerTest=14 -XX:+ErrorFileToStdout -XX:+Use${gc}GC --version > ${gc}_old.txt
> ../fastdebug-new/jdk/bin/java -XX:ErrorHandlerTest=14 -XX:+ErrorFileToStdout -XX:+Use${gc}GC --version > ${gc}_new.txt
Marked as reviewed by ayang (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/24387#pullrequestreview-2739525769
More information about the hotspot-gc-dev
mailing list