1 /*
2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
80 _minor_pause_young_estimator =
81 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
82 _minor_collection_estimator =
83 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
84 _major_collection_estimator =
85 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
86
87 // Start the timers
88 _minor_timer.start();
89
90 _young_gen_policy_is_ready = false;
91 }
92
93 // If the number of GC threads was set on the command line,
94 // use it.
95 // Else
96 // Calculate the number of GC threads based on the number of Java threads.
97 // Calculate the number of GC threads based on the size of the heap.
98 // Use the larger.
99
100 int AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
101 const uintx min_workers,
102 uintx active_workers,
103 uintx application_workers) {
104 // If the user has specifically set the number of
105 // GC threads, use them.
106
107 // If the user has turned off using a dynamic number of GC threads
108 // or the users has requested a specific number, set the active
109 // number of workers to all the workers.
110
111 uintx new_active_workers = total_workers;
112 uintx prev_active_workers = active_workers;
113 uintx active_workers_by_JT = 0;
114 uintx active_workers_by_heap_size = 0;
115
116 // Always use at least min_workers but use up to
117 // GCThreadsPerJavaThreads * application threads.
118 active_workers_by_JT =
119 MAX2((uintx) GCWorkersPerJavaThread * application_workers,
120 min_workers);
161 }
162 _debug_perturbation = !_debug_perturbation;
163 }
164 assert((new_active_workers <= (uintx) ParallelGCThreads) &&
165 (new_active_workers >= min_workers),
166 "Jiggled active workers too much");
167 }
168
169 if (TraceDynamicGCThreads) {
170 gclog_or_tty->print_cr("GCTaskManager::calc_default_active_workers() : "
171 "active_workers(): " UINTX_FORMAT " new_active_workers: " UINTX_FORMAT " "
172 "prev_active_workers: " UINTX_FORMAT "\n"
173 " active_workers_by_JT: " UINTX_FORMAT " active_workers_by_heap_size: " UINTX_FORMAT,
174 active_workers, new_active_workers, prev_active_workers,
175 active_workers_by_JT, active_workers_by_heap_size);
176 }
177 assert(new_active_workers > 0, "Always need at least 1");
178 return new_active_workers;
179 }
180
181 int AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
182 uintx active_workers,
183 uintx application_workers) {
184 // If the user has specifically set the number of
185 // GC threads, use them.
186
187 // If the user has turned off using a dynamic number of GC threads
188 // or the users has requested a specific number, set the active
189 // number of workers to all the workers.
190
191 int new_active_workers;
192 if (!UseDynamicNumberOfGCThreads ||
193 (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
194 new_active_workers = total_workers;
195 } else {
196 new_active_workers = calc_default_active_workers(total_workers,
197 2, /* Minimum number of workers */
198 active_workers,
199 application_workers);
200 }
201 assert(new_active_workers > 0, "Always need at least 1");
202 return new_active_workers;
203 }
204
205 int AdaptiveSizePolicy::calc_active_conc_workers(uintx total_workers,
206 uintx active_workers,
207 uintx application_workers) {
208 if (!UseDynamicNumberOfGCThreads ||
209 (!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) {
210 return ConcGCThreads;
211 } else {
212 int no_of_gc_threads = calc_default_active_workers(
213 total_workers,
214 1, /* Minimum number of workers */
215 active_workers,
216 application_workers);
217 return no_of_gc_threads;
218 }
219 }
220
221 bool AdaptiveSizePolicy::tenuring_threshold_change() const {
222 return decrement_tenuring_threshold_for_gc_cost() ||
223 increment_tenuring_threshold_for_gc_cost() ||
224 decrement_tenuring_threshold_for_survivor_limit();
225 }
226
227 void AdaptiveSizePolicy::minor_collection_begin() {
228 // Update the interval time
229 _minor_timer.stop();
230 // Save most recent collection time
231 _latest_minor_mutator_interval_seconds = _minor_timer.seconds();
232 _minor_timer.reset();
|
1 /*
2 * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
80 _minor_pause_young_estimator =
81 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
82 _minor_collection_estimator =
83 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
84 _major_collection_estimator =
85 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
86
87 // Start the timers
88 _minor_timer.start();
89
90 _young_gen_policy_is_ready = false;
91 }
92
93 // If the number of GC threads was set on the command line,
94 // use it.
95 // Else
96 // Calculate the number of GC threads based on the number of Java threads.
97 // Calculate the number of GC threads based on the size of the heap.
98 // Use the larger.
99
100 uint AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
101 const uintx min_workers,
102 uintx active_workers,
103 uintx application_workers) {
104 // If the user has specifically set the number of
105 // GC threads, use them.
106
107 // If the user has turned off using a dynamic number of GC threads
108 // or the users has requested a specific number, set the active
109 // number of workers to all the workers.
110
111 uintx new_active_workers = total_workers;
112 uintx prev_active_workers = active_workers;
113 uintx active_workers_by_JT = 0;
114 uintx active_workers_by_heap_size = 0;
115
116 // Always use at least min_workers but use up to
117 // GCThreadsPerJavaThreads * application threads.
118 active_workers_by_JT =
119 MAX2((uintx) GCWorkersPerJavaThread * application_workers,
120 min_workers);
161 }
162 _debug_perturbation = !_debug_perturbation;
163 }
164 assert((new_active_workers <= (uintx) ParallelGCThreads) &&
165 (new_active_workers >= min_workers),
166 "Jiggled active workers too much");
167 }
168
169 if (TraceDynamicGCThreads) {
170 gclog_or_tty->print_cr("GCTaskManager::calc_default_active_workers() : "
171 "active_workers(): " UINTX_FORMAT " new_active_workers: " UINTX_FORMAT " "
172 "prev_active_workers: " UINTX_FORMAT "\n"
173 " active_workers_by_JT: " UINTX_FORMAT " active_workers_by_heap_size: " UINTX_FORMAT,
174 active_workers, new_active_workers, prev_active_workers,
175 active_workers_by_JT, active_workers_by_heap_size);
176 }
177 assert(new_active_workers > 0, "Always need at least 1");
178 return new_active_workers;
179 }
180
181 uint AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
182 uintx active_workers,
183 uintx application_workers) {
184 // If the user has specifically set the number of
185 // GC threads, use them.
186
187 // If the user has turned off using a dynamic number of GC threads
188 // or the users has requested a specific number, set the active
189 // number of workers to all the workers.
190
191 uint new_active_workers;
192 if (!UseDynamicNumberOfGCThreads ||
193 (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
194 new_active_workers = total_workers;
195 } else {
196 new_active_workers = calc_default_active_workers(total_workers,
197 2, /* Minimum number of workers */
198 active_workers,
199 application_workers);
200 }
201 assert(new_active_workers > 0, "Always need at least 1");
202 return new_active_workers;
203 }
204
205 uint AdaptiveSizePolicy::calc_active_conc_workers(uintx total_workers,
206 uintx active_workers,
207 uintx application_workers) {
208 if (!UseDynamicNumberOfGCThreads ||
209 (!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) {
210 return ConcGCThreads;
211 } else {
212 uint no_of_gc_threads = calc_default_active_workers(
213 total_workers,
214 1, /* Minimum number of workers */
215 active_workers,
216 application_workers);
217 return no_of_gc_threads;
218 }
219 }
220
221 bool AdaptiveSizePolicy::tenuring_threshold_change() const {
222 return decrement_tenuring_threshold_for_gc_cost() ||
223 increment_tenuring_threshold_for_gc_cost() ||
224 decrement_tenuring_threshold_for_survivor_limit();
225 }
226
227 void AdaptiveSizePolicy::minor_collection_begin() {
228 // Update the interval time
229 _minor_timer.stop();
230 // Save most recent collection time
231 _latest_minor_mutator_interval_seconds = _minor_timer.seconds();
232 _minor_timer.reset();
|