RFR: Avoid divide by zero error, improve variable names
William Kemper
wkemper at openjdk.org
Thu Dec 22 00:27:16 UTC 2022
On Wed, 21 Dec 2022 23:59:40 GMT, Y. Srinivas Ramakrishna <ysr at openjdk.org> wrote:
>> Depending on when the periodic thread runs the accounting task and how much CPU time the process receives, we may see a very small elapsed process time. Such a time should not be used to compute MMU.
>
> src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp line 106:
>
>> 104: double elapsed_collector_time_s = collector_time_s - _collector_reference_time_s;
>> 105: _collector_reference_time_s = collector_time_s;
>> 106: double minimum_mutator_utilization = ((elapsed_process_time_s - elapsed_collector_time_s) / elapsed_process_time_s) * 100;
>
> Alternative: You could check if result `isnan()` and not use it, although I don't know if divide by zero is costly.
I'd just as soon catch it earlier and I'm not 100% certain that other values won't also cause this error. Also, `isnan` won't flag the result of division by zero (`isinf` would though).
-------------
PR: https://git.openjdk.org/shenandoah/pull/188
More information about the shenandoah-dev
mailing list