RFR: JDK-8262068: Improve G1 Full GC by skipping compaction for regions with high survival ratio [v13]
Thomas Schatzl
tschatzl at openjdk.java.net
Wed Apr 7 10:37:19 UTC 2021
On Thu, 1 Apr 2021 14:43:42 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> Summary
>> -----------
>>
>> Improve G1 Full GC by skip compaction for regions with high survival ratio.
>>
>> Backgroud
>> -----------
>>
>> There are 4 steps in full gc of G1 GC.
>> - mark live objects
>> - prepare forwardee
>> - adjust pointers
>> - compact
>>
>> When full gc occurs, there may be very high percentage of live bytes in some regions. For these regions, it's not efficient to compact them and better to skip them, as there are little space to save but many objects to copy.
>>
>> Description
>> -----------
>>
>> We enhance the full gc implementation for the above situation through following steps:
>> - accumulate live bytes of every hr in mark phase; (already done by JDK-8263495)
>> - skip adding regions with high survial ratio, and set the region with high survival ratio as pinned in _region_attr_table during prepare phase;
>> - nothing special is done in adjust phase, regions with high survial ratio are skipped because of pin setting in the above step;
>> - nothing special is done in compact phase, regions with high survival ratio are skipped because these regions are skipped when adding regions to compaction set in the prepare phase;
>>
>> VM options related
>> -----------
>>
>> - MarkSweepDeadRatio: we reuse this exising vm option to indicate the high survial ratio threhold (100-MarkSweepDeadRatio) in G1.
>> - default value of MarkSweepDeadRatio: 5
>>
>> Test
>> -----------
>>
>> - specjbb2015: no regression
>> - dacapo: (Attachment is the dacapo h2 full gc pause.)
>> - 95% of full gc pauses: 10%-19% improvement.
>> - 5% of full gc pauses: 1.2% improvement.
>> - 0.1% of full gc pauses: -6.16% improvement.
>>
>> $ java -Xmx1g -Xms1g -XX:ParallelGCThreads=4 -Xlog:gc*=info:file=gc.log -jar dacapo-9.12-bach.jar --iterations 5 --size huge --no-pre-iteration-gc h2
>
> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
>
> minor code improvement.
src/hotspot/share/gc/g1/g1FullCollector.cpp line 229:
> 227:
> 228: void G1FullCollector::update_attribute_table(HeapRegion* hr) {
> 229: if (hr->is_free()) {
Another item that has been noted in a recent discussion with @albertnetymk is that with this change "Free" regions are also marked as `normal` in the table. It would be better to keep them as "Invalid".
I.e. something like (incorporating @albertnetymk other suggestion):
if (hr->is_free()) {
return;
} else if (hr->is_closed_archive(...) {
[...]
} else if (hr->is_pinned() || force_pinned) {
[...]
} else {
[...]
}
There is no real difference as "Free" regions should never be referenced anywhere and the code should assert elsewhere. It's still nice to also have "Free" regions as `Invalid` in that table though.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2760
More information about the hotspot-gc-dev
mailing list