RFR: 8334147: Shenandoah: Avoid taking lock for disabled free set logging [v8]

Aleksey Shipilev shade at openjdk.org
Thu Jun 27 17:00:12 UTC 2024


On Thu, 27 Jun 2024 15:55:35 GMT, Xiaolong Peng <xpeng at openjdk.org> wrote:

>> Hi all, 
>> This pull request propose a fix for the issue https://bugs.openjdk.org/browse/JDK-8334147
>> 
>>> There are multiple places in Shenandoah where we take heap lock for potential free set diagnostics. There is no point in taking that lock if we do not report anything. We should at very least take the lock only when logging is actually needed.
>> 
>> Basically it adds a public method ```ShenandoahFreeSet::log_status_with_heap_lock``` which acquire lock when there is need to print logs, also make the ```log_status``` private since not expect it to be called out of ShenandoahFreeSet class.
>> 
>> <s>The change for ShenandoahFreeSet::rebuild is probably debatable, ShenandoahFreeSet::log_status will acquire lock again after ShenandoahFreeSet::rebuild is executed, hence the metrics/information in log may not be always consistent, but it might be fine. </s>
>> 
>> Additional test:
>> - [x] `make test TEST=hotspot_gc_shenandoah`
>> 
>> Test summary
>> ==============================
>>    TEST                                              TOTAL  PASS  FAIL ERROR   
>>    jtreg:test/hotspot/jtreg:hotspot_gc_shenandoah      259   259     0     0   
>> ==============================
>> TEST SUCCESS
>> 
>> 
>> Best,
>> Xiaolong.
>
> Xiaolong Peng has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Accidentally removed a empty line
>  - Method renaming

Also, this reminds me we should add the test that actually goes in with `-Xlog:gc+free=info` to see if we fail any of the asserts or break anything _before_ we actually enable the logging in prod. I suggest a simple test: just an empty main, but run with `-XX:ShenandoahGCHeuristics=aggressive`. Put it here: https://github.com/openjdk/jdk/tree/master/test/hotspot/jtreg/gc/shenandoah/options

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

PR Comment: https://git.openjdk.org/jdk/pull/19915#issuecomment-2195218434


More information about the hotspot-gc-dev mailing list