RFR: 8252103: Parallel heap inspection for ParallelScavengeHeap [v12]

Albert Mingkun Yang ayang at openjdk.java.net
Wed Nov 4 08:29:58 UTC 2020


On Wed, 4 Nov 2020 02:10:16 GMT, Lin Zang <lzang at openjdk.org> wrote:

>> src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp line 581:
>> 
>>> 579:       old_gen()->block_iterate(cl, (size_t)block_index);
>>> 580:     }
>>> 581:   }
>> 
>> The structure seems to suggest that each `if` case could be hit in every iteration, but actually only the third case will be revisited more than once. I wonder if this could be made more explicit.
>
> Thanks Albert! Correct, the OldGen part will be revisit much for frequently.  do you have any clue to optimize this? I was considering the marco like "likely()" but I am not sure whether it is acceptable for hotspot.

I think readability is the issue here; below is my attempt with the new `claim_and_get_block`. Don't think there's any performance diff though.

        
size_t block_index = claimer->claim_and_get_block();
if (block_index == HeapBlockClaimer::EdenIndex) {
  young_gen()->eden_space()->object_iterate(cl);
  block_index = claimer->claim_and_get_block();
}
if (block_index == HeapBlockClaimer::SurvivorIndex) {
  young_gen()->from_space()->object_iterate(cl);
  young_gen()->to_space()->object_iterate(cl);
  block_index = claimer->claim_and_get_block();
}
while (block_index != HeapBlockClaimer::InvalidIndex) {
  old_gen()->object_iterate_block(cl, block_index - HeapBlockClaimer::NumNonOldGenClaims);
  block_index = claimer->claim_and_get_block();
}
        
PS: I didn't test the code, so please take it as a quick sketch.

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

PR: https://git.openjdk.java.net/jdk/pull/25


More information about the hotspot-gc-dev mailing list