RFR: 8287555: Tighten G1 G1BlockOffsetTable::block_start() code
Thomas Schatzl
tschatzl at openjdk.org
Fri Jun 24 08:42:53 UTC 2022
On Fri, 24 Jun 2022 06:50:32 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> 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.
CPU resources like branch prediction/speculative execution aren't free either, and this is a very performance sensitive area of code.
I'm planning to revisit this again for the card scanning code which in 99% of cases takes the aligned path.
-------------
PR: https://git.openjdk.org/jdk/pull/9059
More information about the hotspot-gc-dev
mailing list