author | jprovino |
Tue, 02 Aug 2016 16:39:33 -0400 | |
changeset 40328 | a2851f5f1cf6 |
parent 34650 | b4b00fdee76b |
child 40904 | 5189925f9ece |
permissions | -rw-r--r-- |
33214
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
1 |
/* |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
4 |
* |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
8 |
* |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
14 |
* |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
18 |
* |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
22 |
* |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
23 |
*/ |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
24 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_G1_G1PREDICTIONS_HPP |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1PREDICTIONS_HPP |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
27 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
28 |
#include "utilities/numberSeq.hpp" |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
29 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
30 |
// Utility class containing various helper methods for prediction. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
31 |
class G1Predictions VALUE_OBJ_CLASS_SPEC { |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
32 |
private: |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
33 |
double _sigma; |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
34 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
35 |
// This function is used to estimate the stddev of sample sets. There is some |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
36 |
// special consideration of small sample sets: the actual stddev for them is |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
37 |
// not very useful, so we calculate some value based on the sample average. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
38 |
// Five or more samples yields zero (at that point we use the stddev); fewer |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
39 |
// scale the sample set average linearly from two times the average to 0.5 times |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
40 |
// it. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
41 |
double stddev_estimate(TruncatedSeq const* seq) const { |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
42 |
double estimate = seq->dsd(); |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
43 |
int const samples = seq->num(); |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
44 |
if (samples < 5) { |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
45 |
estimate = MAX2(seq->davg() * (5 - samples) / 2.0, estimate); |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
46 |
} |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
47 |
return estimate; |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
48 |
} |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
49 |
public: |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
50 |
G1Predictions(double sigma) : _sigma(sigma) { |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
51 |
assert(sigma >= 0.0, "Confidence must be larger than or equal to zero"); |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
52 |
} |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
53 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
54 |
// Confidence factor. |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
55 |
double sigma() const { return _sigma; } |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
56 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
57 |
double get_new_prediction(TruncatedSeq const* seq) const { |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
58 |
return seq->davg() + _sigma * stddev_estimate(seq); |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
59 |
} |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
60 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
61 |
#ifndef PRODUCT |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
62 |
static void test(); |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
63 |
#endif |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
64 |
}; |
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
65 |
|
5a00fba36171
8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents:
diff
changeset
|
66 |
#endif // SHARE_VM_GC_G1_G1PREDICTIONS_HPP |