src/share/vm/gc_implementation/shared/allocationStats.hpp

Fri, 10 Jun 2011 15:08:36 -0700

author
minqi
date
Fri, 10 Jun 2011 15:08:36 -0700
changeset 2964
2a241e764894
parent 2788
c69b1043dfb1
child 2972
f75137faa7fe
permissions
-rw-r--r--

6941923: RFE: Handling large log files produced by long running Java Applications
Summary: supply optinal flags to realize gc log rotation
Reviewed-by: ysr, jwilhelm

duke@435 1 /*
trims@2708 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP
stefank@2314 27
stefank@2314 28 #ifndef SERIALGC
stefank@2314 29 #include "gc_implementation/shared/gcUtil.hpp"
stefank@2314 30 #include "memory/allocation.hpp"
stefank@2314 31 #include "utilities/globalDefinitions.hpp"
stefank@2314 32 #endif
stefank@2314 33
duke@435 34 class AllocationStats VALUE_OBJ_CLASS_SPEC {
duke@435 35 // A duration threshold (in ms) used to filter
duke@435 36 // possibly unreliable samples.
duke@435 37 static float _threshold;
duke@435 38
duke@435 39 // We measure the demand between the end of the previous sweep and
duke@435 40 // beginning of this sweep:
duke@435 41 // Count(end_last_sweep) - Count(start_this_sweep)
duke@435 42 // + splitBirths(between) - splitDeaths(between)
ysr@1580 43 // The above number divided by the time since the end of the
duke@435 44 // previous sweep gives us a time rate of demand for blocks
duke@435 45 // of this size. We compute a padded average of this rate as
duke@435 46 // our current estimate for the time rate of demand for blocks
duke@435 47 // of this size. Similarly, we keep a padded average for the time
duke@435 48 // between sweeps. Our current estimate for demand for blocks of
duke@435 49 // this size is then simply computed as the product of these two
duke@435 50 // estimates.
duke@435 51 AdaptivePaddedAverage _demand_rate_estimate;
duke@435 52
ysr@1580 53 ssize_t _desired; // Demand stimate computed as described above
duke@435 54 ssize_t _coalDesired; // desired +/- small-percent for tuning coalescing
duke@435 55
duke@435 56 ssize_t _surplus; // count - (desired +/- small-percent),
duke@435 57 // used to tune splitting in best fit
duke@435 58 ssize_t _bfrSurp; // surplus at start of current sweep
duke@435 59 ssize_t _prevSweep; // count from end of previous sweep
duke@435 60 ssize_t _beforeSweep; // count from before current sweep
duke@435 61 ssize_t _coalBirths; // additional chunks from coalescing
duke@435 62 ssize_t _coalDeaths; // loss from coalescing
duke@435 63 ssize_t _splitBirths; // additional chunks from splitting
duke@435 64 ssize_t _splitDeaths; // loss from splitting
ysr@1580 65 size_t _returnedBytes; // number of bytes returned to list.
duke@435 66 public:
ysr@1580 67 void initialize(bool split_birth = false) {
duke@435 68 AdaptivePaddedAverage* dummy =
duke@435 69 new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight,
duke@435 70 CMS_FLSPadding);
duke@435 71 _desired = 0;
duke@435 72 _coalDesired = 0;
duke@435 73 _surplus = 0;
duke@435 74 _bfrSurp = 0;
duke@435 75 _prevSweep = 0;
duke@435 76 _beforeSweep = 0;
duke@435 77 _coalBirths = 0;
duke@435 78 _coalDeaths = 0;
ysr@2788 79 _splitBirths = (split_birth ? 1 : 0);
duke@435 80 _splitDeaths = 0;
duke@435 81 _returnedBytes = 0;
duke@435 82 }
duke@435 83
duke@435 84 AllocationStats() {
duke@435 85 initialize();
duke@435 86 }
ysr@1580 87
duke@435 88 // The rate estimate is in blocks per second.
duke@435 89 void compute_desired(size_t count,
duke@435 90 float inter_sweep_current,
ysr@1580 91 float inter_sweep_estimate,
ysr@1580 92 float intra_sweep_estimate) {
duke@435 93 // If the latest inter-sweep time is below our granularity
duke@435 94 // of measurement, we may call in here with
duke@435 95 // inter_sweep_current == 0. However, even for suitably small
duke@435 96 // but non-zero inter-sweep durations, we may not trust the accuracy
duke@435 97 // of accumulated data, since it has not been "integrated"
duke@435 98 // (read "low-pass-filtered") long enough, and would be
duke@435 99 // vulnerable to noisy glitches. In such cases, we
duke@435 100 // ignore the current sample and use currently available
duke@435 101 // historical estimates.
ysr@1580 102 // XXX NEEDS TO BE FIXED
ysr@1580 103 // assert(prevSweep() + splitBirths() >= splitDeaths() + (ssize_t)count, "Conservation Principle");
ysr@1580 104 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ysr@1580 105 // "Total Stock" "Not used at this block size"
duke@435 106 if (inter_sweep_current > _threshold) {
ysr@1580 107 ssize_t demand = prevSweep() - (ssize_t)count + splitBirths() - splitDeaths();
ysr@1580 108 // XXX NEEDS TO BE FIXED
ysr@1580 109 // assert(demand >= 0, "Demand should be non-negative");
ysr@1580 110 // Defensive: adjust for imprecision in event counting
ysr@1580 111 if (demand < 0) {
ysr@1580 112 demand = 0;
ysr@1580 113 }
ysr@1580 114 float old_rate = _demand_rate_estimate.padded_average();
duke@435 115 float rate = ((float)demand)/inter_sweep_current;
duke@435 116 _demand_rate_estimate.sample(rate);
ysr@1580 117 float new_rate = _demand_rate_estimate.padded_average();
ysr@1580 118 ssize_t old_desired = _desired;
ysr@2502 119 float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
ysr@2502 120 _desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
ysr@1580 121 if (PrintFLSStatistics > 1) {
ysr@1580 122 gclog_or_tty->print_cr("demand: %d, old_rate: %f, current_rate: %f, new_rate: %f, old_desired: %d, new_desired: %d",
ysr@1580 123 demand, old_rate, rate, new_rate, old_desired, _desired);
ysr@1580 124 }
duke@435 125 }
duke@435 126 }
duke@435 127
duke@435 128 ssize_t desired() const { return _desired; }
ysr@447 129 void set_desired(ssize_t v) { _desired = v; }
ysr@447 130
duke@435 131 ssize_t coalDesired() const { return _coalDesired; }
duke@435 132 void set_coalDesired(ssize_t v) { _coalDesired = v; }
duke@435 133
duke@435 134 ssize_t surplus() const { return _surplus; }
duke@435 135 void set_surplus(ssize_t v) { _surplus = v; }
duke@435 136 void increment_surplus() { _surplus++; }
duke@435 137 void decrement_surplus() { _surplus--; }
duke@435 138
duke@435 139 ssize_t bfrSurp() const { return _bfrSurp; }
duke@435 140 void set_bfrSurp(ssize_t v) { _bfrSurp = v; }
duke@435 141 ssize_t prevSweep() const { return _prevSweep; }
duke@435 142 void set_prevSweep(ssize_t v) { _prevSweep = v; }
duke@435 143 ssize_t beforeSweep() const { return _beforeSweep; }
duke@435 144 void set_beforeSweep(ssize_t v) { _beforeSweep = v; }
duke@435 145
duke@435 146 ssize_t coalBirths() const { return _coalBirths; }
duke@435 147 void set_coalBirths(ssize_t v) { _coalBirths = v; }
duke@435 148 void increment_coalBirths() { _coalBirths++; }
duke@435 149
duke@435 150 ssize_t coalDeaths() const { return _coalDeaths; }
duke@435 151 void set_coalDeaths(ssize_t v) { _coalDeaths = v; }
duke@435 152 void increment_coalDeaths() { _coalDeaths++; }
duke@435 153
duke@435 154 ssize_t splitBirths() const { return _splitBirths; }
duke@435 155 void set_splitBirths(ssize_t v) { _splitBirths = v; }
duke@435 156 void increment_splitBirths() { _splitBirths++; }
duke@435 157
duke@435 158 ssize_t splitDeaths() const { return _splitDeaths; }
duke@435 159 void set_splitDeaths(ssize_t v) { _splitDeaths = v; }
duke@435 160 void increment_splitDeaths() { _splitDeaths++; }
duke@435 161
duke@435 162 NOT_PRODUCT(
duke@435 163 size_t returnedBytes() const { return _returnedBytes; }
duke@435 164 void set_returnedBytes(size_t v) { _returnedBytes = v; }
duke@435 165 )
duke@435 166 };
stefank@2314 167
stefank@2314 168 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP

mercurial