Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/shared/gcUtil.cpp @ 4709:fd2b426c30db
7119908: G1: Cache CSet start region for each worker for subsequent reuse
Summary: Cache workers' calculated starting heap region, used for parallel iteration over the collcection set, for subsequent reuse.
Reviewed-by: tonyp, brutisso
author | johnc |
---|---|
date | Wed, 14 Dec 2011 17:43:55 -0800 |
parents | 1d1603768966 |
children | 78a1b285cda8 |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2189
diff
changeset
|
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1145
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:
1145
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/shared/gcUtil.hpp" | |
0 | 27 |
28 // Catch-all file for utility classes | |
29 | |
30 float AdaptiveWeightedAverage::compute_adaptive_average(float new_sample, | |
31 float average) { | |
32 // We smooth the samples by not using weight() directly until we've | |
33 // had enough data to make it meaningful. We'd like the first weight | |
34 // used to be 1, the second to be 1/2, etc until we have 100/weight | |
35 // samples. | |
36 unsigned count_weight = 100/count(); | |
37 unsigned adaptive_weight = (MAX2(weight(), count_weight)); | |
38 | |
39 float new_avg = exp_avg(average, new_sample, adaptive_weight); | |
40 | |
41 return new_avg; | |
42 } | |
43 | |
44 void AdaptiveWeightedAverage::sample(float new_sample) { | |
45 increment_count(); | |
46 assert(count() != 0, | |
47 "Wraparound -- history would be incorrectly discarded"); | |
48 | |
49 // Compute the new weighted average | |
50 float new_avg = compute_adaptive_average(new_sample, average()); | |
51 set_average(new_avg); | |
52 _last_sample = new_sample; | |
53 } | |
54 | |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
55 void AdaptiveWeightedAverage::print() const { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
56 print_on(tty); |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
57 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
58 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
59 void AdaptiveWeightedAverage::print_on(outputStream* st) const { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
60 guarantee(false, "NYI"); |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
61 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
62 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
63 void AdaptivePaddedAverage::print() const { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
64 print_on(tty); |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
65 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
66 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
67 void AdaptivePaddedAverage::print_on(outputStream* st) const { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
68 guarantee(false, "NYI"); |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
69 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
70 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
71 void AdaptivePaddedNoZeroDevAverage::print() const { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
72 print_on(tty); |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
73 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
74 |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
75 void AdaptivePaddedNoZeroDevAverage::print_on(outputStream* st) const { |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
76 guarantee(false, "NYI"); |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
77 } |
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
78 |
0 | 79 void AdaptivePaddedAverage::sample(float new_sample) { |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
80 // Compute new adaptive weighted average based on new sample. |
0 | 81 AdaptiveWeightedAverage::sample(new_sample); |
82 | |
1145
e018e6884bd8
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
0
diff
changeset
|
83 // Now update the deviation and the padded average. |
0 | 84 float new_avg = average(); |
85 float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg), | |
86 deviation()); | |
87 set_deviation(new_dev); | |
88 set_padded_average(new_avg + padding() * new_dev); | |
89 _last_sample = new_sample; | |
90 } | |
91 | |
92 void AdaptivePaddedNoZeroDevAverage::sample(float new_sample) { | |
93 // Compute our parent classes sample information | |
94 AdaptiveWeightedAverage::sample(new_sample); | |
95 | |
96 float new_avg = average(); | |
97 if (new_sample != 0) { | |
98 // We only create a new deviation if the sample is non-zero | |
99 float new_dev = compute_adaptive_average(fabsd(new_sample - new_avg), | |
100 deviation()); | |
101 | |
102 set_deviation(new_dev); | |
103 } | |
104 set_padded_average(new_avg + padding() * deviation()); | |
105 _last_sample = new_sample; | |
106 } | |
107 | |
108 LinearLeastSquareFit::LinearLeastSquareFit(unsigned weight) : | |
2189
176d0be30214
7016998: gcutil class LinearLeastSquareFit doesn't initialize some of its fields
phh
parents:
1972
diff
changeset
|
109 _sum_x(0), _sum_x_squared(0), _sum_y(0), _sum_xy(0), |
176d0be30214
7016998: gcutil class LinearLeastSquareFit doesn't initialize some of its fields
phh
parents:
1972
diff
changeset
|
110 _intercept(0), _slope(0), _mean_x(weight), _mean_y(weight) {} |
0 | 111 |
112 void LinearLeastSquareFit::update(double x, double y) { | |
113 _sum_x = _sum_x + x; | |
114 _sum_x_squared = _sum_x_squared + x * x; | |
115 _sum_y = _sum_y + y; | |
116 _sum_xy = _sum_xy + x * y; | |
117 _mean_x.sample(x); | |
118 _mean_y.sample(y); | |
119 assert(_mean_x.count() == _mean_y.count(), "Incorrect count"); | |
120 if ( _mean_x.count() > 1 ) { | |
121 double slope_denominator; | |
122 slope_denominator = (_mean_x.count() * _sum_x_squared - _sum_x * _sum_x); | |
123 // Some tolerance should be injected here. A denominator that is | |
124 // nearly 0 should be avoided. | |
125 | |
126 if (slope_denominator != 0.0) { | |
127 double slope_numerator; | |
128 slope_numerator = (_mean_x.count() * _sum_xy - _sum_x * _sum_y); | |
129 _slope = slope_numerator / slope_denominator; | |
130 | |
131 // The _mean_y and _mean_x are decaying averages and can | |
132 // be used to discount earlier data. If they are used, | |
133 // first consider whether all the quantities should be | |
134 // kept as decaying averages. | |
135 // _intercept = _mean_y.average() - _slope * _mean_x.average(); | |
136 _intercept = (_sum_y - _slope * _sum_x) / ((double) _mean_x.count()); | |
137 } | |
138 } | |
139 } | |
140 | |
141 double LinearLeastSquareFit::y(double x) { | |
142 double new_y; | |
143 | |
144 if ( _mean_x.count() > 1 ) { | |
145 new_y = (_intercept + _slope * x); | |
146 return new_y; | |
147 } else { | |
148 return _mean_y.average(); | |
149 } | |
150 } | |
151 | |
152 // Both decrement_will_decrease() and increment_will_decrease() return | |
153 // true for a slope of 0. That is because a change is necessary before | |
154 // a slope can be calculated and a 0 slope will, in general, indicate | |
155 // that no calculation of the slope has yet been done. Returning true | |
156 // for a slope equal to 0 reflects the intuitive expectation of the | |
157 // dependence on the slope. Don't use the complement of these functions | |
158 // since that untuitive expectation is not built into the complement. | |
159 bool LinearLeastSquareFit::decrement_will_decrease() { | |
160 return (_slope >= 0.00); | |
161 } | |
162 | |
163 bool LinearLeastSquareFit::increment_will_decrease() { | |
164 return (_slope <= 0.00); | |
165 } |