RFR: JDK-8262068: Improve G1 Full GC by skipping compaction for regions with high survival ratio [v13]

Albert Mingkun Yang ayang at openjdk.java.net
Wed Apr 7 09:39:37 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.

Changes requested by ayang (Committer).

src/hotspot/share/gc/g1/g1FullCollector.cpp line 238:

> 236:   if (hr->is_closed_archive()) {
> 237:     _region_attr_table.set_closed_archive(hr->hrm_index());
> 238:   } else if (hr->is_pinned()) {

Changing the condition to `hr->is_pinned() || force_pinned` is enough for this method, right?

src/hotspot/share/gc/g1/g1FullCollector.hpp line 101:

> 99:   G1CMBitMap*              mark_bitmap();
> 100:   ReferenceProcessor*      reference_processor();
> 101:   size_t                   live_words(uint region_index) { return _live_stats[region_index]._live_words; }

Could you add range check assertion for `region_index`? The extra spaces can be removed; no need to align with previous methods.

src/hotspot/share/gc/g1/heapRegion.hpp line 174:

> 172:   void reset_compacted_after_full_gc();
> 173:   // Update pinned heap region (not compacted) to be consistent after Full GC.
> 174:   void reset_not_compacted_after_full_gc();

Now that this version uses the existing "pinned" mechanism to skip high-live-ratio regions, this method can retain its original name/implementation, right?

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

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



More information about the hotspot-gc-dev mailing list