RFR: 8354362: Use automatic indentation in CollectedHeap printing [v3]

Thomas Stuefe stuefe at openjdk.org
Thu Apr 17 05:25:54 UTC 2025


On Wed, 16 Apr 2025 14:06:21 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

>> src/hotspot/share/memory/metaspace.cpp line 221:
>> 
>>> 219:   MetaspaceCombinedStats stats = get_combined_statistics();
>>> 220:   out->print("Metaspace");
>>> 221:   out->fill_to(17);
>> 
>> We rely on absolute position here? Will not work well with different indentation levels.
>
> This was intended to align good with how ZGC does it. After some thought I think a better strategy is to add a space at the end of the string before filling, like:
> 
> ```c++
> out->print("Metaspace ");
> out->fill_to(17);
> 
> This still aligns to the 17th column, but will not break printing for deeper indentation levels (currently 6 or more).

Yes that sounds better

>> src/hotspot/share/utilities/vmError.cpp line 1399:
>> 
>>> 1397:       st->cr();
>>> 1398:     }
>>> 1399:     Universe::heap()->print_on_error(st);
>> 
>> Why is print_on_error called outside the indentation scope?
>
> This is because print_on() is in its "own" block, inside "Heap:", while print_on_error() prints its own blocks, like "ZGC Globals:" below. Other GCs behave in the same way.
> 
> 
> Heap:
>  ZHeap           used 7740M, capacity 9216M, max capacity 9216M
>   Cache          1476M (2)
>    size classes  128M (1), 1G (1)
>  Metaspace       used 18526K, committed 18816K, reserved 1114112K
>   class space    used 1603K, committed 1728K, reserved 1048576K
> 
> ZGC Globals:
>  Young Collection:   Mark/51
>  Old Collection:     Mark/18
>  Offset Max:         144G (0x0000002400000000)
>  Page Size Small:    2M
>  Page Size Medium:   32M
> 
> ZGC Metadata Bits:
>  LoadGood:           0x000000000000d000
>  LoadBad:            0x0000000000002000
> ...

Hmm, that may be an indication that this should be in its own error reporting STEP, then? Probably does not matter much, just aesthetics

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24593#discussion_r2048252477
PR Review Comment: https://git.openjdk.org/jdk/pull/24593#discussion_r2048252150


More information about the shenandoah-dev mailing list