RFR: JDK-8264987: G1: Fill BOTs for Survivor-turned-to-Old regions in full gc [v2]
Hamlin Li
mli at openjdk.java.net
Wed Apr 14 12:43:06 UTC 2021
On Wed, 14 Apr 2021 08:25:28 GMT, Stefan Johansson <sjohanss at openjdk.org> wrote:
>> 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.
Hi Stefan, I think the refactoring you suggested is great, I just modified as you suggested and the pre-submit tests run successfully.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3459
More information about the hotspot-gc-dev
mailing list