< prev index next >
src/share/vm/gc/shared/adaptiveSizePolicy.hpp
Print this page
rev 10651 : 6858051: Create GC worker threads dynamically
Reviewed-by:
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, 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.
@@ -29,17 +29,20 @@
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcUtil.hpp"
#include "logging/log.hpp"
#include "memory/allocation.hpp"
#include "memory/universe.hpp"
+#include "runtime/os.hpp"
// This class keeps statistical information and computes the
// size of the heap.
// Forward decls
class elapsedTimer;
class CollectorPolicy;
+class AbstractWorkGang;
+class GCTaskManager;
class AdaptiveSizePolicy : public CHeapObj<mtGC> {
friend class GCAdaptivePolicyCounters;
friend class PSGCAdaptivePolicyCounters;
friend class CMSGCAdaptivePolicyCounters;
@@ -341,10 +344,49 @@
size_t init_promo_size,
size_t init_survivor_size,
double gc_pause_goal_sec,
uint gc_cost_ratio);
+ // Returns the number of GC threads to create at JVM initialization.
+ // Note that the creation of additional threads is connected to the
+ // ergonomic decision on how many threads to use for an upcoming task.
+ // If the user has chosen to control the number of GC workers, they
+ // must all be created at initialization (since the implementation will
+ // never try to create more).
+ static uint initial_number_of_workers() {
+ uint initial_workers = ParallelGCThreads;
+ if (UseDynamicNumberOfGCThreads && FLAG_IS_DEFAULT(ParallelGCThreads)) {
+ initial_workers = MIN2(2U, ParallelGCThreads);
+ }
+
+ return initial_workers;
+ }
+
+ // Create additional workers as needed.
+ // dynamic_workers - number of workers being requested for an upcoming
+ // parallel task.
+ // total_workers - total number of workers. This is the maximum
+ // number possible.
+ // created_workers - number of workers already created. This maybe
+ // less than, equal to, or greater than dynamic workers. If greater than
+ // or equal to dynamic_workers, nothing is done.
+ // worker_type - type of thread.
+ // initializing - true if this is called to get the initial number of
+ // GC workers.
+ // If initializing is true, do a vm exit if the workers cannot be created.
+ // The initializing = true case is for JVM start up and failing to
+ // create all the worker at start should considered a problem so exit.
+ // If initializing = false, there are already some number of worker
+ // threads and a failure would not be optimal but should not be fatal.
+ template <class WorkerType>
+ inline static bool add_workers(WorkerType* holder,
+ uint& active_workers,
+ uint total_workers,
+ uint& created_workers,
+ os::ThreadType worker_type,
+ bool initializing);
+
// Return number default GC threads to use in the next GC.
static uint calc_default_active_workers(uintx total_workers,
const uintx min_workers,
uintx active_workers,
uintx application_workers);
< prev index next >