From 3b5ffc53bb44de7b4fc5cb41c9f7132346826a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=A4sken?= Date: Wed, 9 Oct 2024 15:05:27 +0200 Subject: [PATCH] adjustment from xmas - Update src/hotspot/share/gc/z/zDirector.cpp Co-authored-by: Axel Boldt-Christmas --- src/hotspot/share/gc/z/zDirector.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/z/zDirector.cpp b/src/hotspot/share/gc/z/zDirector.cpp index 32329be7b7e2d..3c0cb660206a2 100644 --- a/src/hotspot/share/gc/z/zDirector.cpp +++ b/src/hotspot/share/gc/z/zDirector.cpp @@ -535,8 +535,20 @@ static double calculate_young_to_old_worker_ratio(const ZDirectorStats& stats) { const size_t reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; const double current_young_bytes_freed_per_gc_time = double(reclaimed_per_young_gc) / double(young_gc_time); const double current_old_bytes_freed_per_gc_time = double(reclaimed_per_old_gc) / double(old_gc_time); - const double old_vs_young_efficiency_ratio = current_young_bytes_freed_per_gc_time == 0 ? std::numeric_limits::infinity() - : current_old_bytes_freed_per_gc_time / current_young_bytes_freed_per_gc_time; + + if (current_young_bytes_freed_per_gc_time == 0.0) { + if (current_old_bytes_freed_per_gc_time == 0.0) { + // Neither young nor old collections have reclaimed any memory. + // Give them equal priority. + return 1.0; + } + + // Only old collections have reclaimed memory. + // Prioritize old. + return ZOldGCThreads; + } + + const double old_vs_young_efficiency_ratio = current_old_bytes_freed_per_gc_time / current_young_bytes_freed_per_gc_time; return old_vs_young_efficiency_ratio; }