RFR: 8304144: G1: Remove unnecessary is_survivor check in G1ClearCardTableTask

Thomas Schatzl tschatzl at openjdk.org
Tue Mar 21 11:00:43 UTC 2023


On Tue, 21 Mar 2023 08:12:21 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

> > But clearing (i.e. marking card clean) today, from my cursory reading of the code, over-writes the `g1_young_gen` value,
> 
> That's correct. Nevertheless, lacking further context, it's impossible to determine whether the mentioned overwrite is appropriate or not. For example in this PR, one doesn't know why the current region can or cannot be a survior-region in the local context.
> 
> The class in which this occurs goes by the name of "G1ClearCardTableTask", so it's logical to utilize a method named "clear_cardtable", without requiring broader knowledge.

Not sure whether an `assert`, which is what we are discussing, needs broader knowledge to be justified. But we've already confirmed that survivor regions can't show up here, so I am fine as is.

> 
> However, having said that, when considering global knowledge, we do know that regions in cset will arrive at this point, and if a freed region later becomes an eden-region, cards are annotated with `g1_young_gen` as allocation grows inside that region -- rendering the clearing in `G1ClearCardTableTask` redundant. Possibly, this redundancy (and potentially other factors) can use some refactoring here, which probably uncovers a more reasonable location for a region-type related assertion.

One option could be checking that the region type is appropriate when adding to that list.

There have been prototypes to lazily clear these values [JDK-8227174](https://bugs.openjdk.org/browse/JDK-8227174), but temporarily abandoned. The memory ordering concerns mentioned there may not be an issue with currently supported architectures any more. I can see if I can dig up the patch from somewhere if wanted.

Orthogonal from that we want to get rid of the `g1_young_card_val` value completely which is just an optimization [JDK-8226731](https://bugs.openjdk.org/browse/JDK-8226731).

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

PR Comment: https://git.openjdk.org/jdk/pull/13023#issuecomment-1477631960


More information about the hotspot-gc-dev mailing list