annotate src/share/vm/memory/allocationStats.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 class AllocationStats VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // A duration threshold (in ms) used to filter
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // possibly unreliable samples.
a61af66fc99e Initial load
duke
parents:
diff changeset
28 static float _threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // We measure the demand between the end of the previous sweep and
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // beginning of this sweep:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Count(end_last_sweep) - Count(start_this_sweep)
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // + splitBirths(between) - splitDeaths(between)
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // The above number divided by the time since the start [END???] of the
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // previous sweep gives us a time rate of demand for blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // of this size. We compute a padded average of this rate as
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // our current estimate for the time rate of demand for blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // of this size. Similarly, we keep a padded average for the time
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // between sweeps. Our current estimate for demand for blocks of
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // this size is then simply computed as the product of these two
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // estimates.
a61af66fc99e Initial load
duke
parents:
diff changeset
42 AdaptivePaddedAverage _demand_rate_estimate;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ssize_t _desired; // Estimate computed as described above
a61af66fc99e Initial load
duke
parents:
diff changeset
45 ssize_t _coalDesired; // desired +/- small-percent for tuning coalescing
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 ssize_t _surplus; // count - (desired +/- small-percent),
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // used to tune splitting in best fit
a61af66fc99e Initial load
duke
parents:
diff changeset
49 ssize_t _bfrSurp; // surplus at start of current sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
50 ssize_t _prevSweep; // count from end of previous sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
51 ssize_t _beforeSweep; // count from before current sweep
a61af66fc99e Initial load
duke
parents:
diff changeset
52 ssize_t _coalBirths; // additional chunks from coalescing
a61af66fc99e Initial load
duke
parents:
diff changeset
53 ssize_t _coalDeaths; // loss from coalescing
a61af66fc99e Initial load
duke
parents:
diff changeset
54 ssize_t _splitBirths; // additional chunks from splitting
a61af66fc99e Initial load
duke
parents:
diff changeset
55 ssize_t _splitDeaths; // loss from splitting
a61af66fc99e Initial load
duke
parents:
diff changeset
56 size_t _returnedBytes; // number of bytes returned to list.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 AdaptivePaddedAverage* dummy =
a61af66fc99e Initial load
duke
parents:
diff changeset
60 new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight,
a61af66fc99e Initial load
duke
parents:
diff changeset
61 CMS_FLSPadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _desired = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _coalDesired = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _surplus = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 _bfrSurp = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _prevSweep = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _beforeSweep = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _coalBirths = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _coalDeaths = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _splitBirths = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _splitDeaths = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _returnedBytes = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 AllocationStats() {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // The rate estimate is in blocks per second.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void compute_desired(size_t count,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 float inter_sweep_current,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 float inter_sweep_estimate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // If the latest inter-sweep time is below our granularity
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // of measurement, we may call in here with
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // inter_sweep_current == 0. However, even for suitably small
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // but non-zero inter-sweep durations, we may not trust the accuracy
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // of accumulated data, since it has not been "integrated"
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // (read "low-pass-filtered") long enough, and would be
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // vulnerable to noisy glitches. In such cases, we
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // ignore the current sample and use currently available
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // historical estimates.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (inter_sweep_current > _threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 ssize_t demand = prevSweep() - count + splitBirths() - splitDeaths();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 float rate = ((float)demand)/inter_sweep_current;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _demand_rate_estimate.sample(rate);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _desired = (ssize_t)(_demand_rate_estimate.padded_average()
a61af66fc99e Initial load
duke
parents:
diff changeset
96 *inter_sweep_estimate);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 ssize_t desired() const { return _desired; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 ssize_t coalDesired() const { return _coalDesired; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void set_coalDesired(ssize_t v) { _coalDesired = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 ssize_t surplus() const { return _surplus; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void set_surplus(ssize_t v) { _surplus = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void increment_surplus() { _surplus++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void decrement_surplus() { _surplus--; }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 ssize_t bfrSurp() const { return _bfrSurp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void set_bfrSurp(ssize_t v) { _bfrSurp = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 ssize_t prevSweep() const { return _prevSweep; }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void set_prevSweep(ssize_t v) { _prevSweep = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 ssize_t beforeSweep() const { return _beforeSweep; }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void set_beforeSweep(ssize_t v) { _beforeSweep = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 ssize_t coalBirths() const { return _coalBirths; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void set_coalBirths(ssize_t v) { _coalBirths = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 void increment_coalBirths() { _coalBirths++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 ssize_t coalDeaths() const { return _coalDeaths; }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void set_coalDeaths(ssize_t v) { _coalDeaths = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void increment_coalDeaths() { _coalDeaths++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 ssize_t splitBirths() const { return _splitBirths; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 void set_splitBirths(ssize_t v) { _splitBirths = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void increment_splitBirths() { _splitBirths++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 ssize_t splitDeaths() const { return _splitDeaths; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void set_splitDeaths(ssize_t v) { _splitDeaths = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 void increment_splitDeaths() { _splitDeaths++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 NOT_PRODUCT(
a61af66fc99e Initial load
duke
parents:
diff changeset
133 size_t returnedBytes() const { return _returnedBytes; }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void set_returnedBytes(size_t v) { _returnedBytes = v; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 )
a61af66fc99e Initial load
duke
parents:
diff changeset
136 };