annotate src/share/vm/gc_implementation/shared/adaptiveSizePolicy.cpp @ 23837:83dc7e55f715 jdk8u102-b02

8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr Reviewed-by: jmasa, drwhite
author poonam
date Mon, 04 Apr 2016 10:59:22 -0700
parents 78bbf4d43a14
children 9965e839280f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10359
diff changeset
2 * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1387
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1387
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1387
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/shared/adaptiveSizePolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_interface/gcCause.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/collectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/timer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "utilities/ostream.hpp"
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
31 #include "utilities/workgroup.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 elapsedTimer AdaptiveSizePolicy::_minor_timer;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 elapsedTimer AdaptiveSizePolicy::_major_timer;
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
34 bool AdaptiveSizePolicy::_debug_perturbation = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // The throughput goal is implemented as
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // _throughput_goal = 1 - ( 1 / (1 + gc_cost_ratio))
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // gc_cost_ratio is the ratio
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // application cost / gc cost
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // For example a gc_cost_ratio of 4 translates into a
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // throughput goal of .80
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 AdaptiveSizePolicy::AdaptiveSizePolicy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
44 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 size_t init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
46 double gc_pause_goal_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 uint gc_cost_ratio) :
a61af66fc99e Initial load
duke
parents:
diff changeset
48 _eden_size(init_eden_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _promo_size(init_promo_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _survivor_size(init_survivor_size),
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _gc_pause_goal_sec(gc_pause_goal_sec),
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _throughput_goal(1.0 - double(1.0 / (1.0 + (double) gc_cost_ratio))),
1387
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
53 _gc_overhead_limit_exceeded(false),
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
54 _print_gc_overhead_limit_would_be_exceeded(false),
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
55 _gc_overhead_limit_count(0),
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _latest_minor_mutator_interval_seconds(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _threshold_tolerance_percent(1.0 + ThresholdTolerance/100.0),
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _young_gen_change_for_minor_throughput(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _old_gen_change_for_major_throughput(0) {
1387
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
60 assert(AdaptiveSizePolicyGCTimeLimitThreshold > 0,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
61 "No opportunity to clear SoftReferences before GC overhead limit");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _avg_minor_pause =
a61af66fc99e Initial load
duke
parents:
diff changeset
63 new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 _avg_minor_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _avg_major_gc_cost = new AdaptiveWeightedAverage(AdaptiveTimeWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _avg_young_live = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _avg_old_live = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _avg_eden_live = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _avg_survived = new AdaptivePaddedAverage(AdaptiveSizePolicyWeight,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 SurvivorPadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _avg_pretenured = new AdaptivePaddedNoZeroDevAverage(
a61af66fc99e Initial load
duke
parents:
diff changeset
75 AdaptiveSizePolicyWeight,
a61af66fc99e Initial load
duke
parents:
diff changeset
76 SurvivorPadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 _minor_pause_old_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
79 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _minor_pause_young_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
81 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _minor_collection_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
83 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _major_collection_estimator =
a61af66fc99e Initial load
duke
parents:
diff changeset
85 new LinearLeastSquareFit(AdaptiveSizePolicyWeight);
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Start the timers
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _minor_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _young_gen_policy_is_ready = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
93 // If the number of GC threads was set on the command line,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
94 // use it.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
95 // Else
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
96 // Calculate the number of GC threads based on the number of Java threads.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
97 // Calculate the number of GC threads based on the size of the heap.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
98 // Use the larger.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
99
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
100 int AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
101 const uintx min_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
102 uintx active_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
103 uintx application_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
104 // If the user has specifically set the number of
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
105 // GC threads, use them.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
106
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
107 // If the user has turned off using a dynamic number of GC threads
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
108 // or the users has requested a specific number, set the active
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
109 // number of workers to all the workers.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
110
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
111 uintx new_active_workers = total_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
112 uintx prev_active_workers = active_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
113 uintx active_workers_by_JT = 0;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
114 uintx active_workers_by_heap_size = 0;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
115
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
116 // Always use at least min_workers but use up to
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
117 // GCThreadsPerJavaThreads * application threads.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
118 active_workers_by_JT =
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
119 MAX2((uintx) GCWorkersPerJavaThread * application_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
120 min_workers);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
121
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
122 // Choose a number of GC threads based on the current size
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
123 // of the heap. This may be complicated because the size of
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
124 // the heap depends on factors such as the thoughput goal.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
125 // Still a large heap should be collected by more GC threads.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
126 active_workers_by_heap_size =
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
127 MAX2((size_t) 2U, Universe::heap()->capacity() / HeapSizePerGCThread);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
128
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
129 uintx max_active_workers =
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
130 MAX2(active_workers_by_JT, active_workers_by_heap_size);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
131
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
132 // Limit the number of workers to the the number created,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
133 // (workers()).
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
134 new_active_workers = MIN2(max_active_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
135 (uintx) total_workers);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
136
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
137 // Increase GC workers instantly but decrease them more
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
138 // slowly.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
139 if (new_active_workers < prev_active_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
140 new_active_workers =
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
141 MAX2(min_workers, (prev_active_workers + new_active_workers) / 2);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
142 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
143
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
144 // Check once more that the number of workers is within the limits.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
145 assert(min_workers <= total_workers, "Minimum workers not consistent with total workers");
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
146 assert(new_active_workers >= min_workers, "Minimum workers not observed");
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
147 assert(new_active_workers <= total_workers, "Total workers not observed");
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
148
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
149 if (ForceDynamicNumberOfGCThreads) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
150 // Assume this is debugging and jiggle the number of GC threads.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
151 if (new_active_workers == prev_active_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
152 if (new_active_workers < total_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
153 new_active_workers++;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
154 } else if (new_active_workers > min_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
155 new_active_workers--;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
156 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
157 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
158 if (new_active_workers == total_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
159 if (_debug_perturbation) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
160 new_active_workers = min_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
161 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
162 _debug_perturbation = !_debug_perturbation;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
163 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
164 assert((new_active_workers <= (uintx) ParallelGCThreads) &&
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
165 (new_active_workers >= min_workers),
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
166 "Jiggled active workers too much");
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
167 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
168
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
169 if (TraceDynamicGCThreads) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
170 gclog_or_tty->print_cr("GCTaskManager::calc_default_active_workers() : "
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
171 "active_workers(): %d new_acitve_workers: %d "
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
172 "prev_active_workers: %d\n"
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
173 " active_workers_by_JT: %d active_workers_by_heap_size: %d",
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10359
diff changeset
174 (int) active_workers, (int) new_active_workers, (int) prev_active_workers,
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10359
diff changeset
175 (int) active_workers_by_JT, (int) active_workers_by_heap_size);
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
176 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
177 assert(new_active_workers > 0, "Always need at least 1");
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
178 return new_active_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
179 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
180
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
181 int AdaptiveSizePolicy::calc_active_workers(uintx total_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
182 uintx active_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
183 uintx application_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
184 // If the user has specifically set the number of
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
185 // GC threads, use them.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
186
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
187 // If the user has turned off using a dynamic number of GC threads
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
188 // or the users has requested a specific number, set the active
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
189 // number of workers to all the workers.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
190
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
191 int new_active_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
192 if (!UseDynamicNumberOfGCThreads ||
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
193 (!FLAG_IS_DEFAULT(ParallelGCThreads) && !ForceDynamicNumberOfGCThreads)) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
194 new_active_workers = total_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
195 } else {
23837
83dc7e55f715 8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
poonam
parents: 17937
diff changeset
196 uintx min_workers = (total_workers == 1) ? 1 : 2;
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
197 new_active_workers = calc_default_active_workers(total_workers,
23837
83dc7e55f715 8076995: gc/ergonomics/TestDynamicNumberOfGCThreads.java failed with java.lang.RuntimeException: 'new_active_workers' missing from stdout/stderr
poonam
parents: 17937
diff changeset
198 min_workers,
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
199 active_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
200 application_workers);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
201 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
202 assert(new_active_workers > 0, "Always need at least 1");
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
203 return new_active_workers;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
204 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
205
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
206 int AdaptiveSizePolicy::calc_active_conc_workers(uintx total_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
207 uintx active_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
208 uintx application_workers) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
209 if (!UseDynamicNumberOfGCThreads ||
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
210 (!FLAG_IS_DEFAULT(ConcGCThreads) && !ForceDynamicNumberOfGCThreads)) {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
211 return ConcGCThreads;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
212 } else {
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
213 int no_of_gc_threads = calc_default_active_workers(
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
214 total_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
215 1, /* Minimum number of workers */
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
216 active_workers,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
217 application_workers);
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
218 return no_of_gc_threads;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
219 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
220 }
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
221
0
a61af66fc99e Initial load
duke
parents:
diff changeset
222 bool AdaptiveSizePolicy::tenuring_threshold_change() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return decrement_tenuring_threshold_for_gc_cost() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
224 increment_tenuring_threshold_for_gc_cost() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
225 decrement_tenuring_threshold_for_survivor_limit();
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 void AdaptiveSizePolicy::minor_collection_begin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // Update the interval time
a61af66fc99e Initial load
duke
parents:
diff changeset
230 _minor_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Save most recent collection time
a61af66fc99e Initial load
duke
parents:
diff changeset
232 _latest_minor_mutator_interval_seconds = _minor_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 _minor_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 _minor_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 void AdaptiveSizePolicy::update_minor_pause_young_estimator(
a61af66fc99e Initial load
duke
parents:
diff changeset
238 double minor_pause_in_ms) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 double eden_size_in_mbytes = ((double)_eden_size)/((double)M);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 _minor_pause_young_estimator->update(eden_size_in_mbytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
241 minor_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 void AdaptiveSizePolicy::minor_collection_end(GCCause::Cause gc_cause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // Update the pause time.
a61af66fc99e Initial load
duke
parents:
diff changeset
246 _minor_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (gc_cause != GCCause::_java_lang_system_gc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
249 UseAdaptiveSizePolicyWithSystemGC) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 double minor_pause_in_seconds = _minor_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 double minor_pause_in_ms = minor_pause_in_seconds * MILLIUNITS;
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Sample for performance counter
a61af66fc99e Initial load
duke
parents:
diff changeset
254 _avg_minor_pause->sample(minor_pause_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Cost of collection (unit-less)
a61af66fc99e Initial load
duke
parents:
diff changeset
257 double collection_cost = 0.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if ((_latest_minor_mutator_interval_seconds > 0.0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
259 (minor_pause_in_seconds > 0.0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 double interval_in_seconds =
a61af66fc99e Initial load
duke
parents:
diff changeset
261 _latest_minor_mutator_interval_seconds + minor_pause_in_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 collection_cost =
a61af66fc99e Initial load
duke
parents:
diff changeset
263 minor_pause_in_seconds / interval_in_seconds;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 _avg_minor_gc_cost->sample(collection_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // Sample for performance counter
a61af66fc99e Initial load
duke
parents:
diff changeset
266 _avg_minor_interval->sample(interval_in_seconds);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // The policy does not have enough data until at least some
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // minor collections have been done.
a61af66fc99e Initial load
duke
parents:
diff changeset
271 _young_gen_policy_is_ready =
a61af66fc99e Initial load
duke
parents:
diff changeset
272 (_avg_minor_gc_cost->count() >= AdaptiveSizePolicyReadyThreshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // Calculate variables used to estimate pause time vs. gen sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
275 double eden_size_in_mbytes = ((double)_eden_size)/((double)M);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 update_minor_pause_young_estimator(minor_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 update_minor_pause_old_estimator(minor_pause_in_ms);
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 if (PrintAdaptiveSizePolicy && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 gclog_or_tty->print("AdaptiveSizePolicy::minor_collection_end: "
a61af66fc99e Initial load
duke
parents:
diff changeset
281 "minor gc cost: %f average: %f", collection_cost,
a61af66fc99e Initial load
duke
parents:
diff changeset
282 _avg_minor_gc_cost->average());
a61af66fc99e Initial load
duke
parents:
diff changeset
283 gclog_or_tty->print_cr(" minor pause: %f minor period %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
284 minor_pause_in_ms,
a61af66fc99e Initial load
duke
parents:
diff changeset
285 _latest_minor_mutator_interval_seconds * MILLIUNITS);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Calculate variable used to estimate collection cost vs. gen sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
289 assert(collection_cost >= 0.0, "Expected to be non-negative");
a61af66fc99e Initial load
duke
parents:
diff changeset
290 _minor_collection_estimator->update(eden_size_in_mbytes, collection_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // Interval times use this timer to measure the mutator time.
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // Reset the timer after the GC pause.
a61af66fc99e Initial load
duke
parents:
diff changeset
295 _minor_timer.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
296 _minor_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 size_t AdaptiveSizePolicy::eden_increment(size_t cur_eden,
a61af66fc99e Initial load
duke
parents:
diff changeset
300 uint percent_change) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 size_t eden_heap_delta;
a61af66fc99e Initial load
duke
parents:
diff changeset
302 eden_heap_delta = cur_eden / 100 * percent_change;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 return eden_heap_delta;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 size_t AdaptiveSizePolicy::eden_increment(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 return eden_increment(cur_eden, YoungGenerationSizeIncrement);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 size_t AdaptiveSizePolicy::eden_decrement(size_t cur_eden) {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 size_t eden_heap_delta = eden_increment(cur_eden) /
a61af66fc99e Initial load
duke
parents:
diff changeset
312 AdaptiveSizeDecrementScaleFactor;
a61af66fc99e Initial load
duke
parents:
diff changeset
313 return eden_heap_delta;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 size_t AdaptiveSizePolicy::promo_increment(size_t cur_promo,
a61af66fc99e Initial load
duke
parents:
diff changeset
317 uint percent_change) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 size_t promo_heap_delta;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 promo_heap_delta = cur_promo / 100 * percent_change;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 return promo_heap_delta;
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 size_t AdaptiveSizePolicy::promo_increment(size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 return promo_increment(cur_promo, TenuredGenerationSizeIncrement);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 size_t AdaptiveSizePolicy::promo_decrement(size_t cur_promo) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 size_t promo_heap_delta = promo_increment(cur_promo);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 promo_heap_delta = promo_heap_delta / AdaptiveSizeDecrementScaleFactor;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 return promo_heap_delta;
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 double AdaptiveSizePolicy::time_since_major_gc() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 _major_timer.stop();
a61af66fc99e Initial load
duke
parents:
diff changeset
335 double result = _major_timer.seconds();
a61af66fc99e Initial load
duke
parents:
diff changeset
336 _major_timer.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
337 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // Linear decay of major gc cost
a61af66fc99e Initial load
duke
parents:
diff changeset
341 double AdaptiveSizePolicy::decaying_major_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 double major_interval = major_gc_interval_average_for_decay();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 double major_gc_cost_average = major_gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
344 double decayed_major_gc_cost = major_gc_cost_average;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 if(time_since_major_gc() > 0.0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 decayed_major_gc_cost = major_gc_cost() *
a61af66fc99e Initial load
duke
parents:
diff changeset
347 (((double) AdaptiveSizeMajorGCDecayTimeScale) * major_interval)
a61af66fc99e Initial load
duke
parents:
diff changeset
348 / time_since_major_gc();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // The decayed cost should always be smaller than the
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // average cost but the vagaries of finite arithmetic could
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // produce a larger value in decayed_major_gc_cost so protect
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // against that.
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return MIN2(major_gc_cost_average, decayed_major_gc_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // Use a value of the major gc cost that has been decayed
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // by the factor
a61af66fc99e Initial load
duke
parents:
diff changeset
360 //
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // average-interval-between-major-gc * AdaptiveSizeMajorGCDecayTimeScale /
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // time-since-last-major-gc
a61af66fc99e Initial load
duke
parents:
diff changeset
363 //
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // if the average-interval-between-major-gc * AdaptiveSizeMajorGCDecayTimeScale
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // is less than time-since-last-major-gc.
a61af66fc99e Initial load
duke
parents:
diff changeset
366 //
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // In cases where there are initial major gc's that
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // are of a relatively high cost but no later major
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // gc's, the total gc cost can remain high because
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // the major gc cost remains unchanged (since there are no major
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // gc's). In such a situation the value of the unchanging
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // major gc cost can keep the mutator throughput below
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // the goal when in fact the major gc cost is becoming diminishingly
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // small. Use the decaying gc cost only to decide whether to
a61af66fc99e Initial load
duke
parents:
diff changeset
375 // adjust for throughput. Using it also to determine the adjustment
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // to be made for throughput also seems reasonable but there is
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // no test case to use to decide if it is the right thing to do
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // don't do it yet.
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 double AdaptiveSizePolicy::decaying_gc_cost() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 double decayed_major_gc_cost = major_gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
382 double avg_major_interval = major_gc_interval_average_for_decay();
a61af66fc99e Initial load
duke
parents:
diff changeset
383 if (UseAdaptiveSizeDecayMajorGCCost &&
a61af66fc99e Initial load
duke
parents:
diff changeset
384 (AdaptiveSizeMajorGCDecayTimeScale > 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
385 (avg_major_interval > 0.00)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 double time_since_last_major_gc = time_since_major_gc();
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // Decay the major gc cost?
a61af66fc99e Initial load
duke
parents:
diff changeset
389 if (time_since_last_major_gc >
a61af66fc99e Initial load
duke
parents:
diff changeset
390 ((double) AdaptiveSizeMajorGCDecayTimeScale) * avg_major_interval) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // Decay using the time-since-last-major-gc
a61af66fc99e Initial load
duke
parents:
diff changeset
393 decayed_major_gc_cost = decaying_major_gc_cost();
a61af66fc99e Initial load
duke
parents:
diff changeset
394 if (PrintGCDetails && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 gclog_or_tty->print_cr("\ndecaying_gc_cost: major interval average:"
a61af66fc99e Initial load
duke
parents:
diff changeset
396 " %f time since last major gc: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
397 avg_major_interval, time_since_last_major_gc);
a61af66fc99e Initial load
duke
parents:
diff changeset
398 gclog_or_tty->print_cr(" major gc cost: %f decayed major gc cost: %f",
a61af66fc99e Initial load
duke
parents:
diff changeset
399 major_gc_cost(), decayed_major_gc_cost);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403 double result = MIN2(1.0, decayed_major_gc_cost + minor_gc_cost());
a61af66fc99e Initial load
duke
parents:
diff changeset
404 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 void AdaptiveSizePolicy::clear_generation_free_space_flags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 set_change_young_gen_for_min_pauses(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
410 set_change_old_gen_for_maj_pauses(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 set_change_old_gen_for_throughput(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
413 set_change_young_gen_for_throughput(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
414 set_decrease_for_footprint(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 set_decide_at_full_gc(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
1387
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
418 void AdaptiveSizePolicy::check_gc_overhead_limit(
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
419 size_t young_live,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
420 size_t eden_live,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
421 size_t max_old_gen_size,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
422 size_t max_eden_size,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
423 bool is_full_gc,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
424 GCCause::Cause gc_cause,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
425 CollectorPolicy* collector_policy) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
426
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
427 // Ignore explicit GC's. Exiting here does not set the flag and
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
428 // does not reset the count. Updating of the averages for system
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
429 // GC's is still controlled by UseAdaptiveSizePolicyWithSystemGC.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
430 if (GCCause::is_user_requested_gc(gc_cause) ||
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
431 GCCause::is_serviceability_requested_gc(gc_cause)) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
432 return;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
433 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
434 // eden_limit is the upper limit on the size of eden based on
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
435 // the maximum size of the young generation and the sizes
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
436 // of the survivor space.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
437 // The question being asked is whether the gc costs are high
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
438 // and the space being recovered by a collection is low.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
439 // free_in_young_gen is the free space in the young generation
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
440 // after a collection and promo_live is the free space in the old
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
441 // generation after a collection.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
442 //
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
443 // Use the minimum of the current value of the live in the
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
444 // young gen or the average of the live in the young gen.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
445 // If the current value drops quickly, that should be taken
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
446 // into account (i.e., don't trigger if the amount of free
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
447 // space has suddenly jumped up). If the current is much
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
448 // higher than the average, use the average since it represents
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
449 // the longer term behavor.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
450 const size_t live_in_eden =
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
451 MIN2(eden_live, (size_t) avg_eden_live()->average());
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
452 const size_t free_in_eden = max_eden_size > live_in_eden ?
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
453 max_eden_size - live_in_eden : 0;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
454 const size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average());
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
455 const size_t total_free_limit = free_in_old_gen + free_in_eden;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
456 const size_t total_mem = max_old_gen_size + max_eden_size;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
457 const double mem_free_limit = total_mem * (GCHeapFreeLimit/100.0);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
458 const double mem_free_old_limit = max_old_gen_size * (GCHeapFreeLimit/100.0);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
459 const double mem_free_eden_limit = max_eden_size * (GCHeapFreeLimit/100.0);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
460 const double gc_cost_limit = GCTimeLimit/100.0;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
461 size_t promo_limit = (size_t)(max_old_gen_size - avg_old_live()->average());
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
462 // But don't force a promo size below the current promo size. Otherwise,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
463 // the promo size will shrink for no good reason.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
464 promo_limit = MAX2(promo_limit, _promo_size);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
465
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
466
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
467 if (PrintAdaptiveSizePolicy && (Verbose ||
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
468 (free_in_old_gen < (size_t) mem_free_old_limit &&
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
469 free_in_eden < (size_t) mem_free_eden_limit))) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
470 gclog_or_tty->print_cr(
10359
14d3f71f831d 8007762: Rename a bunch of methods in size policy across collectors
tamao
parents: 6818
diff changeset
471 "PSAdaptiveSizePolicy::check_gc_overhead_limit:"
1387
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
472 " promo_limit: " SIZE_FORMAT
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
473 " max_eden_size: " SIZE_FORMAT
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
474 " total_free_limit: " SIZE_FORMAT
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
475 " max_old_gen_size: " SIZE_FORMAT
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
476 " max_eden_size: " SIZE_FORMAT
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
477 " mem_free_limit: " SIZE_FORMAT,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
478 promo_limit, max_eden_size, total_free_limit,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
479 max_old_gen_size, max_eden_size,
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
480 (size_t) mem_free_limit);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
481 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
482
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
483 bool print_gc_overhead_limit_would_be_exceeded = false;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
484 if (is_full_gc) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
485 if (gc_cost() > gc_cost_limit &&
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
486 free_in_old_gen < (size_t) mem_free_old_limit &&
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
487 free_in_eden < (size_t) mem_free_eden_limit) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
488 // Collections, on average, are taking too much time, and
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
489 // gc_cost() > gc_cost_limit
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
490 // we have too little space available after a full gc.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
491 // total_free_limit < mem_free_limit
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
492 // where
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
493 // total_free_limit is the free space available in
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
494 // both generations
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
495 // total_mem is the total space available for allocation
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
496 // in both generations (survivor spaces are not included
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
497 // just as they are not included in eden_limit).
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
498 // mem_free_limit is a fraction of total_mem judged to be an
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
499 // acceptable amount that is still unused.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
500 // The heap can ask for the value of this variable when deciding
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
501 // whether to thrown an OutOfMemory error.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
502 // Note that the gc time limit test only works for the collections
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
503 // of the young gen + tenured gen and not for collections of the
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
504 // permanent gen. That is because the calculation of the space
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
505 // freed by the collection is the free space in the young gen +
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
506 // tenured gen.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
507 // At this point the GC overhead limit is being exceeded.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
508 inc_gc_overhead_limit_count();
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
509 if (UseGCOverheadLimit) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
510 if (gc_overhead_limit_count() >=
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
511 AdaptiveSizePolicyGCTimeLimitThreshold){
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
512 // All conditions have been met for throwing an out-of-memory
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
513 set_gc_overhead_limit_exceeded(true);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
514 // Avoid consecutive OOM due to the gc time limit by resetting
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
515 // the counter.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
516 reset_gc_overhead_limit_count();
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
517 } else {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
518 // The required consecutive collections which exceed the
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
519 // GC time limit may or may not have been reached. We
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
520 // are approaching that condition and so as not to
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
521 // throw an out-of-memory before all SoftRef's have been
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
522 // cleared, set _should_clear_all_soft_refs in CollectorPolicy.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
523 // The clearing will be done on the next GC.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
524 bool near_limit = gc_overhead_limit_near();
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
525 if (near_limit) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
526 collector_policy->set_should_clear_all_soft_refs(true);
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
527 if (PrintGCDetails && Verbose) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
528 gclog_or_tty->print_cr(" Nearing GC overhead limit, "
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
529 "will be clearing all SoftReference");
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
530 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
531 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
532 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
533 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
534 // Set this even when the overhead limit will not
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
535 // cause an out-of-memory. Diagnostic message indicating
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
536 // that the overhead limit is being exceeded is sometimes
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
537 // printed.
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
538 print_gc_overhead_limit_would_be_exceeded = true;
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
539
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
540 } else {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
541 // Did not exceed overhead limits
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
542 reset_gc_overhead_limit_count();
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
543 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
544 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
545
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
546 if (UseGCOverheadLimit && PrintGCDetails && Verbose) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
547 if (gc_overhead_limit_exceeded()) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
548 gclog_or_tty->print_cr(" GC is exceeding overhead limit "
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10359
diff changeset
549 "of %d%%", (int) GCTimeLimit);
1387
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
550 reset_gc_overhead_limit_count();
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
551 } else if (print_gc_overhead_limit_would_be_exceeded) {
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
552 assert(gc_overhead_limit_count() > 0, "Should not be printing");
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
553 gclog_or_tty->print_cr(" GC would exceed overhead limit "
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
554 "of %d%% %d consecutive time(s)",
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10359
diff changeset
555 (int) GCTimeLimit, gc_overhead_limit_count());
1387
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
556 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
557 }
0bfd3fb24150 6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents: 0
diff changeset
558 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
559 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 bool AdaptiveSizePolicy::print_adaptive_size_policy_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // Should only be used with adaptive size policy turned on.
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // Otherwise, there may be variables that are undefined.
a61af66fc99e Initial load
duke
parents:
diff changeset
565 if (!UseAdaptiveSizePolicy) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // Print goal for which action is needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
568 char* action = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
569 bool change_for_pause = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
570 if ((change_old_gen_for_maj_pauses() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
571 decrease_old_gen_for_maj_pauses_true) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
572 (change_young_gen_for_min_pauses() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
573 decrease_young_gen_for_min_pauses_true)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
574 action = (char*) " *** pause time goal ***";
a61af66fc99e Initial load
duke
parents:
diff changeset
575 change_for_pause = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 } else if ((change_old_gen_for_throughput() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
577 increase_old_gen_for_throughput_true) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
578 (change_young_gen_for_throughput() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
579 increase_young_gen_for_througput_true)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
580 action = (char*) " *** throughput goal ***";
a61af66fc99e Initial load
duke
parents:
diff changeset
581 } else if (decrease_for_footprint()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
582 action = (char*) " *** reduced footprint ***";
a61af66fc99e Initial load
duke
parents:
diff changeset
583 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // No actions were taken. This can legitimately be the
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // situation if not enough data has been gathered to make
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // decisions.
a61af66fc99e Initial load
duke
parents:
diff changeset
587 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
589
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // Pauses
a61af66fc99e Initial load
duke
parents:
diff changeset
591 // Currently the size of the old gen is only adjusted to
a61af66fc99e Initial load
duke
parents:
diff changeset
592 // change the major pause times.
a61af66fc99e Initial load
duke
parents:
diff changeset
593 char* young_gen_action = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
594 char* tenured_gen_action = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596 char* shrink_msg = (char*) "(attempted to shrink)";
a61af66fc99e Initial load
duke
parents:
diff changeset
597 char* grow_msg = (char*) "(attempted to grow)";
a61af66fc99e Initial load
duke
parents:
diff changeset
598 char* no_change_msg = (char*) "(no change)";
a61af66fc99e Initial load
duke
parents:
diff changeset
599 if (change_young_gen_for_min_pauses() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
600 decrease_young_gen_for_min_pauses_true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
601 young_gen_action = shrink_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
602 } else if (change_for_pause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
603 young_gen_action = no_change_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 if (change_old_gen_for_maj_pauses() == decrease_old_gen_for_maj_pauses_true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 tenured_gen_action = shrink_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
608 } else if (change_for_pause) {
a61af66fc99e Initial load
duke
parents:
diff changeset
609 tenured_gen_action = no_change_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
610 }
a61af66fc99e Initial load
duke
parents:
diff changeset
611
a61af66fc99e Initial load
duke
parents:
diff changeset
612 // Throughput
a61af66fc99e Initial load
duke
parents:
diff changeset
613 if (change_old_gen_for_throughput() == increase_old_gen_for_throughput_true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
614 assert(change_young_gen_for_throughput() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
615 increase_young_gen_for_througput_true,
a61af66fc99e Initial load
duke
parents:
diff changeset
616 "Both generations should be growing");
a61af66fc99e Initial load
duke
parents:
diff changeset
617 young_gen_action = grow_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
618 tenured_gen_action = grow_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 } else if (change_young_gen_for_throughput() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
620 increase_young_gen_for_througput_true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
621 // Only the young generation may grow at start up (before
a61af66fc99e Initial load
duke
parents:
diff changeset
622 // enough full collections have been done to grow the old generation).
a61af66fc99e Initial load
duke
parents:
diff changeset
623 young_gen_action = grow_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
624 tenured_gen_action = no_change_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626
a61af66fc99e Initial load
duke
parents:
diff changeset
627 // Minimum footprint
a61af66fc99e Initial load
duke
parents:
diff changeset
628 if (decrease_for_footprint() != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 young_gen_action = shrink_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
630 tenured_gen_action = shrink_msg;
a61af66fc99e Initial load
duke
parents:
diff changeset
631 }
a61af66fc99e Initial load
duke
parents:
diff changeset
632
a61af66fc99e Initial load
duke
parents:
diff changeset
633 st->print_cr(" UseAdaptiveSizePolicy actions to meet %s", action);
a61af66fc99e Initial load
duke
parents:
diff changeset
634 st->print_cr(" GC overhead (%%)");
a61af66fc99e Initial load
duke
parents:
diff changeset
635 st->print_cr(" Young generation: %7.2f\t %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
636 100.0 * avg_minor_gc_cost()->average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
637 young_gen_action);
a61af66fc99e Initial load
duke
parents:
diff changeset
638 st->print_cr(" Tenured generation: %7.2f\t %s",
a61af66fc99e Initial load
duke
parents:
diff changeset
639 100.0 * avg_major_gc_cost()->average(),
a61af66fc99e Initial load
duke
parents:
diff changeset
640 tenured_gen_action);
a61af66fc99e Initial load
duke
parents:
diff changeset
641 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
643
a61af66fc99e Initial load
duke
parents:
diff changeset
644 bool AdaptiveSizePolicy::print_adaptive_size_policy_on(
a61af66fc99e Initial load
duke
parents:
diff changeset
645 outputStream* st,
6818
22b8d3d181d9 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 4095
diff changeset
646 uint tenuring_threshold_arg) const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
647 if (!AdaptiveSizePolicy::print_adaptive_size_policy_on(st)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 // Tenuring threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
652 bool tenuring_threshold_changed = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
653 if (decrement_tenuring_threshold_for_survivor_limit()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
654 st->print(" Tenuring threshold: (attempted to decrease to avoid"
a61af66fc99e Initial load
duke
parents:
diff changeset
655 " survivor space overflow) = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
656 } else if (decrement_tenuring_threshold_for_gc_cost()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
657 st->print(" Tenuring threshold: (attempted to decrease to balance"
a61af66fc99e Initial load
duke
parents:
diff changeset
658 " GC costs) = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
659 } else if (increment_tenuring_threshold_for_gc_cost()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
660 st->print(" Tenuring threshold: (attempted to increase to balance"
a61af66fc99e Initial load
duke
parents:
diff changeset
661 " GC costs) = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
662 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
663 tenuring_threshold_changed = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
664 assert(!tenuring_threshold_change(), "(no change was attempted)");
a61af66fc99e Initial load
duke
parents:
diff changeset
665 }
a61af66fc99e Initial load
duke
parents:
diff changeset
666 if (tenuring_threshold_changed) {
6818
22b8d3d181d9 8000351: Tenuring threshold should be unsigned
jwilhelm
parents: 4095
diff changeset
667 st->print_cr("%u", tenuring_threshold_arg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
669 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }