author | mikael |
Tue, 09 Oct 2012 10:09:34 -0700 | |
changeset 13963 | e5b53c306fb5 |
parent 12509 | 6228e2085074 |
child 15482 | 470d0b0c09f1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13963
e5b53c306fb5
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
12509
diff
changeset
|
2 |
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4574
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4574
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4574
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP |
26 |
#define SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP |
|
27 |
||
28 |
#ifndef SERIALGC |
|
29 |
#include "gc_implementation/shared/gcUtil.hpp" |
|
30 |
#include "memory/allocation.hpp" |
|
31 |
#include "utilities/globalDefinitions.hpp" |
|
32 |
#endif |
|
33 |
||
1 | 34 |
class AllocationStats VALUE_OBJ_CLASS_SPEC { |
35 |
// A duration threshold (in ms) used to filter |
|
36 |
// possibly unreliable samples. |
|
37 |
static float _threshold; |
|
38 |
||
39 |
// We measure the demand between the end of the previous sweep and |
|
40 |
// beginning of this sweep: |
|
41 |
// Count(end_last_sweep) - Count(start_this_sweep) |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
42 |
// + split_births(between) - split_deaths(between) |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
43 |
// The above number divided by the time since the end of the |
1 | 44 |
// previous sweep gives us a time rate of demand for blocks |
45 |
// of this size. We compute a padded average of this rate as |
|
46 |
// our current estimate for the time rate of demand for blocks |
|
47 |
// of this size. Similarly, we keep a padded average for the time |
|
48 |
// between sweeps. Our current estimate for demand for blocks of |
|
49 |
// this size is then simply computed as the product of these two |
|
50 |
// estimates. |
|
51 |
AdaptivePaddedAverage _demand_rate_estimate; |
|
52 |
||
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
53 |
ssize_t _desired; // Demand stimate computed as described above |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
54 |
ssize_t _coal_desired; // desired +/- small-percent for tuning coalescing |
1 | 55 |
|
56 |
ssize_t _surplus; // count - (desired +/- small-percent), |
|
57 |
// used to tune splitting in best fit |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
58 |
ssize_t _bfr_surp; // surplus at start of current sweep |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
59 |
ssize_t _prev_sweep; // count from end of previous sweep |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
60 |
ssize_t _before_sweep; // count from before current sweep |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
61 |
ssize_t _coal_births; // additional chunks from coalescing |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
62 |
ssize_t _coal_deaths; // loss from coalescing |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
63 |
ssize_t _split_births; // additional chunks from splitting |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
64 |
ssize_t _split_deaths; // loss from splitting |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
65 |
size_t _returned_bytes; // number of bytes returned to list. |
1 | 66 |
public: |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
67 |
void initialize(bool split_birth = false) { |
1 | 68 |
AdaptivePaddedAverage* dummy = |
69 |
new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight, |
|
70 |
CMS_FLSPadding); |
|
71 |
_desired = 0; |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
72 |
_coal_desired = 0; |
1 | 73 |
_surplus = 0; |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
74 |
_bfr_surp = 0; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
75 |
_prev_sweep = 0; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
76 |
_before_sweep = 0; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
77 |
_coal_births = 0; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
78 |
_coal_deaths = 0; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
79 |
_split_births = (split_birth ? 1 : 0); |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
80 |
_split_deaths = 0; |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
81 |
_returned_bytes = 0; |
1 | 82 |
} |
83 |
||
84 |
AllocationStats() { |
|
85 |
initialize(); |
|
86 |
} |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
87 |
|
1 | 88 |
// The rate estimate is in blocks per second. |
89 |
void compute_desired(size_t count, |
|
90 |
float inter_sweep_current, |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
91 |
float inter_sweep_estimate, |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
92 |
float intra_sweep_estimate) { |
1 | 93 |
// If the latest inter-sweep time is below our granularity |
94 |
// of measurement, we may call in here with |
|
95 |
// inter_sweep_current == 0. However, even for suitably small |
|
96 |
// but non-zero inter-sweep durations, we may not trust the accuracy |
|
97 |
// of accumulated data, since it has not been "integrated" |
|
98 |
// (read "low-pass-filtered") long enough, and would be |
|
99 |
// vulnerable to noisy glitches. In such cases, we |
|
100 |
// ignore the current sample and use currently available |
|
101 |
// historical estimates. |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
102 |
assert(prev_sweep() + split_births() + coal_births() // "Total Production Stock" |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
103 |
>= split_deaths() + coal_deaths() + (ssize_t)count, // "Current stock + depletion" |
9998
f5cb52083a7c
6916968: CMS: freeList.cpp:304 assert(_allocation_stats.prevSweep() + ..., "Conservation Principle")
ysr
parents:
9183
diff
changeset
|
104 |
"Conservation Principle"); |
1 | 105 |
if (inter_sweep_current > _threshold) { |
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
106 |
ssize_t demand = prev_sweep() - (ssize_t)count + split_births() + coal_births() |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
107 |
- split_deaths() - coal_deaths(); |
9998
f5cb52083a7c
6916968: CMS: freeList.cpp:304 assert(_allocation_stats.prevSweep() + ..., "Conservation Principle")
ysr
parents:
9183
diff
changeset
|
108 |
assert(demand >= 0, |
f5cb52083a7c
6916968: CMS: freeList.cpp:304 assert(_allocation_stats.prevSweep() + ..., "Conservation Principle")
ysr
parents:
9183
diff
changeset
|
109 |
err_msg("Demand (" SSIZE_FORMAT ") should be non-negative for " |
f5cb52083a7c
6916968: CMS: freeList.cpp:304 assert(_allocation_stats.prevSweep() + ..., "Conservation Principle")
ysr
parents:
9183
diff
changeset
|
110 |
PTR_FORMAT " (size=" SIZE_FORMAT ")", |
f5cb52083a7c
6916968: CMS: freeList.cpp:304 assert(_allocation_stats.prevSweep() + ..., "Conservation Principle")
ysr
parents:
9183
diff
changeset
|
111 |
demand, this, count)); |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
112 |
// Defensive: adjust for imprecision in event counting |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
113 |
if (demand < 0) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
114 |
demand = 0; |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
115 |
} |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
116 |
float old_rate = _demand_rate_estimate.padded_average(); |
1 | 117 |
float rate = ((float)demand)/inter_sweep_current; |
118 |
_demand_rate_estimate.sample(rate); |
|
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
119 |
float new_rate = _demand_rate_estimate.padded_average(); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
120 |
ssize_t old_desired = _desired; |
8101
1778246610fa
6999988: CMS: Increased fragmentation leading to promotion failure after CR#6631166 got implemented
ysr
parents:
7397
diff
changeset
|
121 |
float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0); |
1778246610fa
6999988: CMS: Increased fragmentation leading to promotion failure after CR#6631166 got implemented
ysr
parents:
7397
diff
changeset
|
122 |
_desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise)); |
4574
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
123 |
if (PrintFLSStatistics > 1) { |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
124 |
gclog_or_tty->print_cr("demand: %d, old_rate: %f, current_rate: %f, new_rate: %f, old_desired: %d, new_desired: %d", |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
125 |
demand, old_rate, rate, new_rate, old_desired, _desired); |
b2d5b0975515
6631166: CMS: better heuristics when combatting fragmentation
ysr
parents:
670
diff
changeset
|
126 |
} |
1 | 127 |
} |
128 |
} |
|
129 |
||
130 |
ssize_t desired() const { return _desired; } |
|
185
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
131 |
void set_desired(ssize_t v) { _desired = v; } |
cda2a1eb4be5
6668743: CMS: Consolidate block statistics reporting code
ysr
parents:
1
diff
changeset
|
132 |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
133 |
ssize_t coal_desired() const { return _coal_desired; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
134 |
void set_coal_desired(ssize_t v) { _coal_desired = v; } |
1 | 135 |
|
136 |
ssize_t surplus() const { return _surplus; } |
|
137 |
void set_surplus(ssize_t v) { _surplus = v; } |
|
138 |
void increment_surplus() { _surplus++; } |
|
139 |
void decrement_surplus() { _surplus--; } |
|
140 |
||
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
141 |
ssize_t bfr_surp() const { return _bfr_surp; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
142 |
void set_bfr_surp(ssize_t v) { _bfr_surp = v; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
143 |
ssize_t prev_sweep() const { return _prev_sweep; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
144 |
void set_prev_sweep(ssize_t v) { _prev_sweep = v; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
145 |
ssize_t before_sweep() const { return _before_sweep; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
146 |
void set_before_sweep(ssize_t v) { _before_sweep = v; } |
1 | 147 |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
148 |
ssize_t coal_births() const { return _coal_births; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
149 |
void set_coal_births(ssize_t v) { _coal_births = v; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
150 |
void increment_coal_births() { _coal_births++; } |
1 | 151 |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
152 |
ssize_t coal_deaths() const { return _coal_deaths; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
153 |
void set_coal_deaths(ssize_t v) { _coal_deaths = v; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
154 |
void increment_coal_deaths() { _coal_deaths++; } |
1 | 155 |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
156 |
ssize_t split_births() const { return _split_births; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
157 |
void set_split_births(ssize_t v) { _split_births = v; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
158 |
void increment_split_births() { _split_births++; } |
1 | 159 |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
160 |
ssize_t split_deaths() const { return _split_deaths; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
161 |
void set_split_deaths(ssize_t v) { _split_deaths = v; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
162 |
void increment_split_deaths() { _split_deaths++; } |
1 | 163 |
|
164 |
NOT_PRODUCT( |
|
12509
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
165 |
size_t returned_bytes() const { return _returned_bytes; } |
6228e2085074
7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents:
9998
diff
changeset
|
166 |
void set_returned_bytes(size_t v) { _returned_bytes = v; } |
1 | 167 |
) |
168 |
}; |
|
7397 | 169 |
|
170 |
#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP |