RFR: 8287555: Tighten G1 G1BlockOffsetTable::block_start() code

Thomas Schatzl tschatzl at openjdk.org
Fri Jun 24 06:54:54 UTC 2022


On Thu, 23 Jun 2022 21:19:58 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

>> Hi all,
>> 
>>   can I have reviews for this change that specializes `G1BlockOffsetTablePart::block_size` with a variant used for card aligned addresses including some cleanup of comments? This saves some unnecessary lookup of the block size of the object found as for refinement the start address is always aligned.
>> 
>> Testing: tier1, gha
>> 
>> Thanks,
>>   Thomas
>
> src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp line 166:
> 
>> 164:   // Returns the address of the start of the block containing "addr", assuming that
>> 165:   // the given address is card-aligned.
>> 166:   inline HeapWord* block_start_aligned(const void* addr) const;
> 
> I am not sure introducing another API is really that necessary. What I have in mind is sth like:
> 
> 
> void block_start(const void* addr) {
>   if (card_aligned(addr)) {
>     fast_path
>   } else {
>     slow_path
>   }
>   assert_post-cond
> }
> 
> 
> I don't think the cost of if-check will be observable.

I had something like that, but the "not observable" part was not that clear in my results (i.e. during garbage collection; "not clear" as in it seems to be slower) so I only optimized the part where this can be statically determined for now.

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

PR: https://git.openjdk.org/jdk/pull/9059



More information about the hotspot-gc-dev mailing list