RFR: 8339648: ZGC: Division by zero in rule_major_allocation_rate [v2]
Axel Boldt-Christmas
aboldtch at openjdk.org
Fri Sep 13 09:19:04 UTC 2024
On Fri, 13 Sep 2024 09:00:00 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> src/hotspot/share/gc/z/zDirector.cpp line 490:
>>
>>> 488:
>>> 489: // Calculate the GC cost for each reclaimed byte
>>> 490: const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc);
>>
>> Could this division have the same issue?
>
> Yes, it could if no memory has been reclaimed at all (since the VM started). Similar issues would occur in the call to `calculate_extra_young_gc_time` below. And there I think the problem is even worse, because we might end up with `inf - inf == -nan`.
The case where we have performed a major collection and no young collection has reclaim any memory seems like a very degenerate situation. The solution is probably to handle that case separately, and not try to adapt the current heuristics to handle the extreme values.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20888#discussion_r1758502503
More information about the hotspot-gc-dev
mailing list