RFR: 8191565: Last-ditch Full GC should also move humongous objects [v2]

Stefan Johansson sjohanss at openjdk.org
Wed Mar 15 13:23:25 UTC 2023


On Mon, 6 Mar 2023 10:22:27 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:

>> Hi All,
>> 
>> Please review this change to move humongous regions during the Last-Ditch full gc ( on `do_maximal_compaction`). This change will enable G1 to avoid encountering Out-Of-Memory errors that may occur due to the fragmentation of memory regions caused by the allocation of large memory blocks.
>> 
>> Here's how it works: At the end of `phase2_prepare_compaction`, G1 performs a serial compaction process for regular objects, which results in the heap being divided into two parts. The first part is a densely populated prefix that contains all the regular objects that have been moved. The second part consists of the remaining heap space, which may contain free regions, uncommitted regions, and regions that are not compacting. By moving/compacting the humongous objects in the second part of the heap closer to the dense prefix, G1 reduces the region fragmentation and avoids running into OOM errors.
>> 
>> We have enabled for G1 the Jtreg test that was previously used only for Shenandoah to test such workload. 
>> 
>> Testing: Tier 1-3
>
> Ivan Walulya has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Refactor resetting humongous metadata
>  - Thomas review

Overall it looks good, just a couple of small comments below. 

Many thanks for taking on this change.

src/hotspot/share/gc/g1/g1CollectedHeap.hpp line 609:

> 607:   inline void register_humongous_candidate_region_with_region_attr(uint index);
> 608: 
> 609:   void reset_humongous_metadata(HeapRegion* first_hr,

I would go with just `set_humongous_metadata(...)`

src/hotspot/share/gc/g1/g1FullGCCompactionPoint.hpp line 47:

> 45:   void switch_region();
> 46:   HeapRegion* next_region();
> 47:   Pair<uint, uint> find_contiguous_before(HeapRegion* hr, uint num_regions);

I think we can skip returning a `Pair` here. The second value is only used to check if we found any range and instead we could use something like `UINT_MAX` or the max number of regions to mark that.

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

Changes requested by sjohanss (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12830


More information about the hotspot-gc-dev mailing list