RFR: JDK-8264987: G1: Fill BOTs for Survivor-turned-to-Old regions in full gc
Stefan Johansson
sjohanss at openjdk.java.net
Wed Apr 14 07:19:57 UTC 2021
On Wed, 14 Apr 2021 04:23:20 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> Hi Stefan, Thanks for the suggestion.
>> At first thought, I think it's a good way to reuse the traversal ability of HeapRegion::apply_to_marked_objects.
>>
>> But when I try to implement it actually, seems to me it might make the code a little complicated.
>>
>> For the first part, in the new G1UpdateBotClosure, we need to indroduce an _pre_addr as you suggested. this part is implemented as below, it's not that complicated, please check the following code snippet:
>>
>> void G1FullGCPrepareTask::G1CalculatePointersClosure::update_bot(HeapRegion* hr) {
>> G1UpdateBotClosure updateBot(hr);
>> hr->apply_to_marked_objects(_bitmap, &updateBot);
>> }
>>
>> G1FullGCPrepareTask::G1UpdateBotClosure::G1UpdateBotClosure(HeapRegion* hr) :
>> _hr(hr),
>> _pre_addr(hr->bottom()),
>> _threshold(hr->initialize_threshold()) { }
>>
>> size_t G1FullGCPrepareTask::G1UpdateBotClosure::apply(oop object) {
>> HeapWord* addr = cast_from_oop<HeapWord*>(object);
>> size_t size = object->size();
>> HeapWord* next_addr = addr + size;
>>
>> if(addr > _threshold) {
>> _threshold = _hr->cross_threshold(_pre_addr, addr);
>> }
>> if (next_addr > _threshold) {
>> _threshold = _hr->cross_threshold(addr, next_addr);
>> }
>> _pre_addr = next_addr;+ return size;
>> }
>>
>>
>>
>> But, the above code does not consider the situation: one or several dead objects are at the end of the heap region, at this situation, we needs to update the bot outside of the G1UpdateBotClosure after hr->apply_to_marked_objects(...). I did not implement this part yet, but seems to me it makes the code a little complicated and not that readable, so would like to discuss with you first.
>>
>> In summary, seems it does not make the code more readable, and will increase the complexity.
>> How do you think about it?
>
> BTW, may I ask what's the format do you use the quote a snippet of code, seems my snippet of code lost all format info(e.g. indent).
Easiest is to mark the code and push the "Insert code" button (<>). You can also manually write ``` to start a code block.
I'll get back to you about the code above later.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3459
More information about the hotspot-gc-dev
mailing list