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 08:27:58 UTC 2021
On Wed, 14 Apr 2021 07:42:28 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> 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.
>
> Thanks Stefan, it works.
Looked a bit more at the code now and I agree that it didn't become as neat as I had hoped. Solving the problem you describe with dead objects at the end should be fairly easy in the closure-destructor I guess. Something like:
~G1UpdateBotClosure() {
if (_hr->top() > _threshold) {
_hr->cross_threshold(_pre_addr, _hr->top());
}
}
And a few comments in the apply method will help readability:
size_t apply(oop object) {
size_t size = object->size();
HeapWord* addr = cast_from_oop<HeapWord*>(object);
HeapWord* next_addr = addr + size;
// Threshold was crossed by dead object.
if(addr > _threshold) {
_threshold = _hr->cross_threshold(_pre_addr, addr);
}
// Threshold is crossed by this object.
if (next_addr > _threshold) {
_threshold = _hr->cross_threshold(addr, next_addr);
}
_pre_addr = next_addr;
return size;
}
But still it might be better to instead streamline the current approach:
Suggestion:
HeapWord* limit = hr->top();
HeapWord* next_addr = hr->bottom();
HeapWord* threshold = hr->initialize_threshold();
HeapWord* pre_addr;
while (next_addr < limit) {
pre_addr = next_addr;
next_addr = _bitmap->get_next_marked_addr(next_addr + 1, limit);
if (next_addr > threshold) {
threshold = hr->cross_threshold(pre_addr, next_addr);
}
}
assert(next_addr == limit, "Should stop the scan at the limit.");
}
Here I removed the `Prefetch` because we do not need to touch the heap. For this to be true I also removed the small optimization to use `obj->size()`, which is probably not an optimization if we don't need to do anything with the "object".
After doing this I agree that reusing `apply_to_marked_objects()` is probably not helping.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3459
More information about the hotspot-gc-dev
mailing list