RFR: 8343782: G1: Use one G1CardSet instance for multiple old gen regions [v4]

Albert Mingkun Yang ayang at openjdk.org
Mon Dec 9 09:07:45 UTC 2024


On Tue, 3 Dec 2024 19:56:23 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:

>> Hi all,
>> 
>> Please review this change to assign multiple collection candidate regions to a single instance of a G1CardSet. Currently, we maintain a 1:1 mapping of old-gen regions and G1CardSet instances, assuming these regions are collected independently. However, regions are collected in batches for performance reasons to meet the G1MixedGCCountTarget.
>> 
>> In this change, at the end of the Remark phase, we batch regions that we anticipate will be collected together into a collection group while selecting remembered set rebuild candidates. Regions in a collection group should be evacuated at the same time because they are assigned to the same G1CardSet instances. This implies that we do not need to maintain cross-region remembered set entries for regions within the same collection group.
>> 
>> The benefit is a reduction in the memory overhead of the remembered set and the remembered set merge time during the collection pause. One disadvantage is that this approach decreases the flexibility during evacuation: you can only evacuate all regions that share a particular G1CardSet at the same time. Another downside is that pinned regions that are part of a collection group have to be partially evacuated when the collection group is selected for evacuation. This removes the optimization in the mainline implementation where the pinned regions are skipped to allow for potential unpinning before evacuation.
>> 
>> In this change, we make significant changes to the collection set implementation as we switch to group selection instead of region selection. Consequently, many of the changes in the PR are about switching from region-centered collection set selection to a group-centered approach.
>> 
>> Note: The batching is based on the sort order by reclaimable bytes which may change the evacuation order in which regions would have been evacuated when sorted by gc efficiency.
>> 
>> We have not observed any regressions on internal performance testing platforms. Memory comparisons for the Cachestress benchmark for different heap sizes are attached below.
>> 
>> Testing: Mach5 Tier1-6
>> 
>> ![16GB](https://github.com/user-attachments/assets/3224c2f1-172d-4d76-ba28-bf483b1b1c95)
>> ![32G](https://github.com/user-attachments/assets/abd10537-41a9-4cf9-b668-362af12fe949)
>> ![64GB](https://github.com/user-attachments/assets/fa87eefc-cf8a-4fb5-9fc4-e7151498bf73)
>> ![128GB](https://github.com/user-attachments/assets/c3a59e32-6bd7-43e3-a3e4-c472f71aa544)
>
> Ivan Walulya has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Albert Review

src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 3055:

> 3053: }
> 3054: 
> 3055: void G1CollectedHeap::prepare_group_cardsets_for_scan () {

Pre-existing: extra space.

src/hotspot/share/gc/g1/g1CollectionSet.cpp line 655:

> 653:     G1HeapRegion* r = ci._r;
> 654:     r->uninstall_group_cardset();
> 655:     r->rem_set()->set_state_complete();

Why changing the remset state here? I'd expect it's already complete; otherwise, how can it be added to cset?

src/hotspot/share/gc/g1/g1CollectionSet.inline.hpp line 32:

> 30: 
> 31: template <class CardOrRangeVisitor>
> 32: inline void G1CollectionSet::merge_cardsets_for_collection_groups(G1CollectedHeap* g1h, CardOrRangeVisitor& cl, uint worker_id, uint num_workers) {

The first arg seems unused.

src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp line 38:

> 36: { }
> 37: 
> 38: void G1CSetCandidateGroup::add(G1HeapRegion* hr) {

I believe this method is only for retained regions; if so, one can make that explicit by naming it sth like `add_region_region`.

src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp line 45:

> 43: void G1CSetCandidateGroup::add(G1CollectionSetCandidateInfo& hr_info) {
> 44:   G1HeapRegion* hr = hr_info._r;
> 45:   assert(!hr->is_young(), "should be flagged as survivor region");

Can one assert region is Old here?

src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp line 180:

> 178: void G1CSetCandidateGroupList::prepare_for_scan() {
> 179:   for (G1CSetCandidateGroup* gr : _groups) {
> 180:     gr->card_set()->reset_table_scanner();

This is a group card set, so why not calling `reset_table_scanner_for_groups`?

src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp line 345:

> 343:   G1CSetCandidateGroupList other_marking_groups;
> 344:   G1CSetCandidateGroupList other_retained_groups;
> 345: 

Extra blank line.

src/hotspot/share/gc/g1/g1HeapRegion.cpp line 144:

> 142:   if (is_young() || is_free()) {
> 143:     return -1.0;
> 144:   }

I don't get why young-regions are treated specially. Also, it's weird that "free" region needs to have a gc-efficiency.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1874099261
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1874028649
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1873380805
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1873276256
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1873280032
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1874100872
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1873300822
PR Review Comment: https://git.openjdk.org/jdk/pull/22015#discussion_r1873254478


More information about the hotspot-gc-dev mailing list