RFR: 8334147: Shenandoah: Avoid taking lock for free set logging
Xiaolong Peng
xpeng at openjdk.org
Wed Jun 26 22:45:20 UTC 2024
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 moves the ShenandoahHeapLocker into ShenandoahFreeSet::log_status and only acquire heap lock when log is actually enabled. Since the lock is not a reentrant lock, re-arrangement of code related to ShenandoahFreeSet::rebuild is needed.
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.
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.
-------------
Commit messages:
- Add shenandoah_assert_not_heaplocked
- 8334147: Shenandoah: Avoid taking lock for free set logging
- Move free_set()->log_status() out of ShenandoahFullGC::phase5_epilog
- code format
- Restructure code of ShenandoahFreeSet::finish_rebuild to move log_status out of it to avoid re-entering heap lock
- Shenandoah: Avoid taking lock for free set logging
Changes: https://git.openjdk.org/jdk/pull/19915/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19915&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8334147
Stats: 27 lines in 5 files changed: 6 ins; 10 del; 11 mod
Patch: https://git.openjdk.org/jdk/pull/19915.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19915/head:pull/19915
PR: https://git.openjdk.org/jdk/pull/19915
More information about the hotspot-gc-dev
mailing list