< prev index next >

src/hotspot/share/gc/shared/adaptiveSizePolicy.cpp

Print this page
rev 52689 : 8213224: Move code related to GC threads calculation out of AdaptiveSizePolicy
Summary: Consolidate code related to GC threads calculation into a single class

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -22,22 +22,18 @@
  *
  */
 
 #include "precompiled.hpp"
 #include "gc/shared/adaptiveSizePolicy.hpp"
-#include "gc/shared/collectorPolicy.hpp"
 #include "gc/shared/gcCause.hpp"
 #include "gc/shared/gcUtil.inline.hpp"
 #include "gc/shared/softRefPolicy.hpp"
-#include "gc/shared/workgroup.hpp"
 #include "logging/log.hpp"
 #include "runtime/timer.hpp"
-#include "utilities/ostream.hpp"
 
 elapsedTimer AdaptiveSizePolicy::_minor_timer;
 elapsedTimer AdaptiveSizePolicy::_major_timer;
-bool AdaptiveSizePolicy::_debug_perturbation = false;
 
 // The throughput goal is implemented as
 //      _throughput_goal = 1 - ( 1 / (1 + gc_cost_ratio))
 // gc_cost_ratio is the ratio
 //      application cost / gc cost

@@ -92,133 +88,10 @@
   _minor_timer.start();
 
   _young_gen_policy_is_ready = false;
 }
 
-//  If the number of GC threads was set on the command line,
-// use it.
-//  Else
-//    Calculate the number of GC threads based on the number of Java threads.
-//    Calculate the number of GC threads based on the size of the heap.
-//    Use the larger.
-
-uint AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
-                                                     const uintx min_workers,
-                                                     uintx active_workers,
-                                                     uintx application_workers) {
-  // If the user has specifically set the number of
-  // GC threads, use them.
-
-  // If the user has turned off using a dynamic number of GC threads
-  // or the users has requested a specific number, set the active
-  // number of workers to all the workers.
-
-  uintx new_active_workers = total_workers;
-  uintx prev_active_workers = active_workers;
-  uintx active_workers_by_JT = 0;
-  uintx active_workers_by_heap_size = 0;
-
-  // Always use at least min_workers but use up to
-  // GCThreadsPerJavaThreads * application threads.
-  active_workers_by_JT =
-    MAX2((uintx) GCWorkersPerJavaThread * application_workers,
-         min_workers);
-
-  // Choose a number of GC threads based on the current size
-  // of the heap.  This may be complicated because the size of
-  // the heap depends on factors such as the throughput goal.
-  // Still a large heap should be collected by more GC threads.
-  active_workers_by_heap_size =
-      MAX2((size_t) 2U, Universe::heap()->capacity() / HeapSizePerGCThread);
-
-  uintx max_active_workers =
-    MAX2(active_workers_by_JT, active_workers_by_heap_size);
-
-  new_active_workers = MIN2(max_active_workers, (uintx) total_workers);
-
-  // Increase GC workers instantly but decrease them more
-  // slowly.
-  if (new_active_workers < prev_active_workers) {
-    new_active_workers =
-      MAX2(min_workers, (prev_active_workers + new_active_workers) / 2);
-  }
-
-  // Check once more that the number of workers is within the limits.
-  assert(min_workers <= total_workers, "Minimum workers not consistent with total workers");
-  assert(new_active_workers >= min_workers, "Minimum workers not observed");
-  assert(new_active_workers <= total_workers, "Total workers not observed");
-
-  if (ForceDynamicNumberOfGCThreads) {
-    // Assume this is debugging and jiggle the number of GC threads.
-    if (new_active_workers == prev_active_workers) {
-      if (new_active_workers < total_workers) {
-        new_active_workers++;
-      } else if (new_active_workers > min_workers) {
-        new_active_workers--;
-      }
-    }
-    if (new_active_workers == total_workers) {
-      if (_debug_perturbation) {
-        new_active_workers =  min_workers;
-      }
-      _debug_perturbation = !_debug_perturbation;
-    }
-    assert((new_active_workers <= ParallelGCThreads) &&
-           (new_active_workers >= min_workers),
-      "Jiggled active workers too much");
-  }
-
-  log_trace(gc, task)("GCTaskManager::calc_default_active_workers() : "
-     "active_workers(): " UINTX_FORMAT "  new_active_workers: " UINTX_FORMAT "  "
-     "prev_active_workers: " UINTX_FORMAT "\n"
-     " active_workers_by_JT: " UINTX_FORMAT "  active_workers_by_heap_size: " UINTX_FORMAT,
-     active_workers, new_active_workers, prev_active_workers,
-     active_workers_by_JT, active_workers_by_heap_size);
-  assert(new_active_workers > 0, "Always need at least 1");
-  return new_active_workers;
-}
-
-uint AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
-                                             uintx active_workers,
-                                             uintx application_workers) {
-  // If the user has specifically set the number of
-  // GC threads, use them.
-
-  // If the user has turned off using a dynamic number of GC threads
-  // or the users has requested a specific number, set the active
-  // number of workers to all the workers.
-
-  uint new_active_workers;
-  if (!UseDynamicNumberOfGCThreads ||
-     (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
-    new_active_workers = total_workers;
-  } else {
-    uintx min_workers = (total_workers == 1) ? 1 : 2;
-    new_active_workers = calc_default_active_workers(total_workers,
-                                                     min_workers,
-                                                     active_workers,
-                                                     application_workers);
-  }
-  assert(new_active_workers > 0, "Always need at least 1");
-  return new_active_workers;
-}
-
-uint AdaptiveSizePolicy::calc_active_conc_workers(uintx total_workers,
-                                                  uintx active_workers,
-                                                  uintx application_workers) {
-  if (!UseDynamicNumberOfGCThreads ||
-     (!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) {
-    return ConcGCThreads;
-  } else {
-    uint no_of_gc_threads = calc_default_active_workers(total_workers,
-                                                        1, /* Minimum number of workers */
-                                                        active_workers,
-                                                        application_workers);
-    return no_of_gc_threads;
-  }
-}
-
 bool AdaptiveSizePolicy::tenuring_threshold_change() const {
   return decrement_tenuring_threshold_for_gc_cost() ||
          increment_tenuring_threshold_for_gc_cost() ||
          decrement_tenuring_threshold_for_survivor_limit();
 }
< prev index next >