RFR: 8331711: G1 doesn't need pre write barrier for stores from new allocated objects [v2]

Erik Österlund eosterlund at openjdk.org
Wed May 8 11:30:54 UTC 2024


On Wed, 8 May 2024 06:10:52 GMT, Liang Mao <lmao at openjdk.org> wrote:

>> I think that store capturing of initializing stores already removes most of the barriers of this category. We do that a bit later on. We find initializing stores onto newly allocated objects, and replace the store with barriers, with a store without barriers. That one usually elides a large portion of store barriers. Did you find any example where you have a newly allocated object with stores that are not initializing, hence not elided, which unnecessarily invoked a pre-write barrier, but not a post-write barrier? Just trying to find out what the problem space is, that this fixes.
>
>> I think that store capturing of initializing stores already removes most of the barriers of this category. We do that a bit later on. We find initializing stores onto newly allocated objects, and replace the store with barriers, with a store without barriers. That one usually elides a large portion of store barriers. Did you find any example where you have a newly allocated object with stores that are not initializing, hence not elided, which unnecessarily invoked a pre-write barrier, but not a post-write barrier? Just trying to find out what the problem space is, that this fixes.
> 
> Hi Erik,  I found examples not filtered by g1_can_remove_pre_barrier in testing. But I just did some statistics on SPECjbb2015 that if g1_can_remove_pre_barrier ran first it would elide most of the pre-barriers and "obj == kit->just_allocated_object"  only found very few remaining opportunities. If we run condition "obj == kit->just_allocated_object" first, it would cover ~30% opportunities. I think technically this PR should be correct but it's up to reviewers to decide if we practically need it.

Did you check how many of the stores where g1_can_remove_pre_barrier said false and you would have said true, were elided anyway during store capturing (cf. InitializeNode::capture_store), or as part of G1BarrierSetC2::eliminate_gc_barrier? In other words, how many barriers are you eliding, that were not in fact already elided, just a bit later on?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19098#discussion_r1593874081


More information about the hotspot-gc-dev mailing list