RFR: 8329570: G1: Excessive is_obj_dead_cond calls in verification

Guoxiong Li gli at openjdk.org
Wed Apr 3 10:46:09 UTC 2024


On Wed, 3 Apr 2024 08:53:18 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> While investigating [JDK-8329314](https://bugs.openjdk.org/browse/JDK-8329314) it was found that G1 was slower than Parallel when allocating objects because of the extra verification when running with fastdebug builds.
> 
> This tiny tests takes 30s with G1:
> 
> public class Test {
>     static int n = 847734685;
> 
>     public static void main(String[] args) {
>          String[] strs = new String[n + 1];
>     }
> }
> 
> 
> A large portion of that time is spent inside this assert:
> 
>     assert(!G1CollectedHeap::heap()->is_obj_dead_cond(_containing_obj, _vo), "Precondition");
> 
> which is called for every single oop in the _containing_obj. If I move this assert to where _containing_obj is initialized, the test now completes in 4-5 seconds. I propose that we make this tiny change to improve the speed of the debug builds.

Looks good. One question/suggestion.

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

> 625:   void set_containing_obj(oop const obj) {
> 626:     assert(!G1CollectedHeap::heap()->is_obj_dead_cond(obj, _vo), "Precondition");
> 627:     _containing_obj = obj;

Should the method `set_containing_obj` judge whether the `obj` is `null`? Just like the `do_oop_work`.

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

Marked as reviewed by gli (Committer).

PR Review: https://git.openjdk.org/jdk/pull/18595#pullrequestreview-1976351371
PR Review Comment: https://git.openjdk.org/jdk/pull/18595#discussion_r1549459239


More information about the hotspot-gc-dev mailing list