Skip to content

Commit d793fd1

Browse files
author
William Kemper
committedDec 21, 2022
Avoid divide by zero error, improve variable names
Reviewed-by: kdnilsen
1 parent da95011 commit d793fd1

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed
 

‎src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
2929
#include "gc/shenandoah/shenandoahOldGeneration.hpp"
3030
#include "gc/shenandoah/shenandoahYoungGeneration.hpp"
31+
#include "logging/log.hpp"
3132
#include "runtime/os.hpp"
3233
#include "runtime/task.hpp"
33-
#include "logging/log.hpp"
3434

3535

3636
class ShenandoahMmuTask : public PeriodicTask {
@@ -94,12 +94,17 @@ void ShenandoahMmuTracker::report() {
9494
// This is only called by the periodic thread.
9595
double process_time_s = process_time_seconds();
9696
double elapsed_process_time_s = process_time_s - _process_reference_time_s;
97+
if (elapsed_process_time_s <= 0.01) {
98+
// No cpu time for this interval?
99+
return;
100+
}
101+
97102
_process_reference_time_s = process_time_s;
98-
double verify_time_s = gc_thread_time_seconds();
99-
double verify_elapsed = verify_time_s - _collector_reference_time_s;
100-
_collector_reference_time_s = verify_time_s;
101-
double verify_mmu = ((elapsed_process_time_s - verify_elapsed) / elapsed_process_time_s) * 100;
102-
_mmu_average.add(verify_mmu);
103+
double collector_time_s = gc_thread_time_seconds();
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;
107+
_mmu_average.add(minimum_mutator_utilization);
103108
log_info(gc)("Average MMU = %.3f", _mmu_average.davg());
104109
}
105110

0 commit comments

Comments
 (0)
Please sign in to comment.