RFR: JDK-8262068: Improve G1 Full GC by skipping compaction for regions with high survival ratio [v11]
Stefan Johansson
sjohanss at openjdk.java.net
Fri Mar 26 09:25:29 UTC 2021
On Thu, 25 Mar 2021 12:28:58 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 with a new target base due to a merge or a rebase. The pull request now contains seven commits:
>
> - Merge branch 'master' into g1-full-gc-optimization-00
> - reuse the "pin" mechanism (G1FullCollector._region_attr_table) to skip region compaction;
> deal with last-ditch full gc;
> - Merge branch 'master' into g1-full-gc-optimization-00
> - fix bot crash.
> - fix crash in G1CalculatePointersClosure::prepare_for_skipping_compaction when klass of dead objects is unloaded;
> other misc improvements.
> - reuse vm option MarkSweepDeadRatio; reuse G1RegionMarkStatsCache class; fix regression in Mark phase by inlining live words collection into mark_object()
> - JDK-8262068: Improve G1 Full GC by skipping compaction for regions with high survival ratio
src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp line 83:
> 81: // Reset data structures not valid after Full GC.
> 82: reset_region_metadata(hr);
> 83: _collector->update_attribute_table(hr, force_pinned);
@tschatzl, this call was here since before (but without the force part). Why is it needed? The call to `update_attribute_table()` will return straight away if the region has been free and to me it looks like that is the only change that can have occurred at this point. If it is not needed for other reasons, instead of adding the `force_pinned` part we could just add a `set_pinned()` helper to the `G1FullCollector` to make it more clear what is happening.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2760
More information about the hotspot-gc-dev
mailing list