RFR: 8264008: Incorrect metaspace statistics after JEP 387 when UseCompressedClassPointers is off [v2]

Thomas Stuefe stuefe at openjdk.java.net
Tue Mar 23 16:54:41 UTC 2021


On Tue, 23 Mar 2021 07:43:58 GMT, Jie Fu <jiefu at openjdk.org> wrote:

>> Hi all,
>> 
>> Metaspace statistics is incorrect after JEP 387 when UseCompressedClassPointers is off.
>> 
>> For example, here is the incorrect metaspace statistics before the fix:
>> Event:jdk.MetaspaceSummary {
>>   startTime = 10:35:24.762
>>   gcId = 3
>>   when = "Before GC"
>>   gcThreshold = 21.0 MB
>>   metaspace = {
>>     committed = 10.3 MB
>>     used = 10.2 MB
>>     reserved = 16.0 MB
>>   }
>>   dataSpace = {
>>     committed = 10.3 MB
>>     used = 10.2 MB
>>     reserved = 16.0 MB
>>   }
>>   classSpace = {
>>     committed = 10.3 MB
>>     used = 10.2 MB
>>     reserved = 16.0 MB
>>   }
>> }
>> 
>> This bug can be reproduced by running the following tests with `-XX:-UseCompressedClassPointers`, which would pass before JEP 387.
>> jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java
>> jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java
>> jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java
>> 
>> The failing reason is that `Metaspace::is_class_space_allocation(mdtype)` [1] will always return false when `UseCompressedClassPointers` is off.
>> So `RunningCounters::committed_words_nonclass()` will be returned even called with `Metaspace::is_class_space_allocation(Metaspace::ClassType)`, which is unreasonable.
>> And `MetaspaceUtils::reserved_words(Metaspace::MetadataType mdtype)`/`MetaspaceUtils::used_words(Metaspace::MetadataType mdtype)` also suffer from the same bug.
>> 
>> Thanks.
>> Best regards,
>> Jie
>> 
>> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/memory/metaspace.cpp#L90
>> 
>> 
>> Metaspace statistics after the fix:
>> Event:jdk.MetaspaceSummary {
>>   startTime = 10:44:38.230
>>   gcId = 1
>>   when = "After GC"
>>   gcThreshold = 21.0 MB
>>   metaspace = {
>>     committed = 10.3 MB
>>     used = 10.2 MB
>>     reserved = 16.0 MB
>>   }
>>   dataSpace = {
>>     committed = 10.3 MB
>>     used = 10.2 MB
>>     reserved = 16.0 MB
>>   }
>>   classSpace = {
>>     committed = 0 bytes
>>     used = 0 bytes
>>     reserved = 0 bytes
>>   }
>> }
>
> Jie Fu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add a test run to reproduce the bug

Hi Jie,

thanks for adding the test. Notes inline.

Cheers, Thomas

test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java line 46:

> 44:  * @library /test/lib /test/jdk
> 45:  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseSerialGC -XX:-UseCompressedClassPointers
> 46:  *                   jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial

I would exclude 32bit here since it would just re-run the same test as above. Does the 32bit VM even accept UseCompressedClassPointers?

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

Changes requested by stuefe (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3142


More information about the hotspot-runtime-dev mailing list