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

Thu, 13 Feb 2014 17:44:39 +0100

author
stefank
date
Thu, 13 Feb 2014 17:44:39 +0100
changeset 6971
7426d8d76305
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
permissions
-rw-r--r--

8034761: Remove the do_code_roots parameter from process_strong_roots
Reviewed-by: tschatzl, mgerdin, jmasa

duke@435 1 /*
drchase@6680 2 * Copyright (c) 2001, 2014, 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
jprovino@4542 28 #include "utilities/macros.hpp"
stefank@2314 29 #include "memory/allocation.hpp"
stefank@2314 30 #include "utilities/globalDefinitions.hpp"
dholmes@5689 31 #include "gc_implementation/shared/gcUtil.hpp"
stefank@2314 32
duke@435 33 class AllocationStats VALUE_OBJ_CLASS_SPEC {
duke@435 34 // A duration threshold (in ms) used to filter
duke@435 35 // possibly unreliable samples.
duke@435 36 static float _threshold;
duke@435 37
duke@435 38 // We measure the demand between the end of the previous sweep and
duke@435 39 // beginning of this sweep:
duke@435 40 // Count(end_last_sweep) - Count(start_this_sweep)
jmasa@3732 41 // + split_births(between) - split_deaths(between)
ysr@1580 42 // The above number divided by the time since the end of the
duke@435 43 // previous sweep gives us a time rate of demand for blocks
duke@435 44 // of this size. We compute a padded average of this rate as
duke@435 45 // our current estimate for the time rate of demand for blocks
duke@435 46 // of this size. Similarly, we keep a padded average for the time
duke@435 47 // between sweeps. Our current estimate for demand for blocks of
duke@435 48 // this size is then simply computed as the product of these two
duke@435 49 // estimates.
duke@435 50 AdaptivePaddedAverage _demand_rate_estimate;
duke@435 51
ysr@1580 52 ssize_t _desired; // Demand stimate computed as described above
jmasa@3732 53 ssize_t _coal_desired; // desired +/- small-percent for tuning coalescing
duke@435 54
duke@435 55 ssize_t _surplus; // count - (desired +/- small-percent),
duke@435 56 // used to tune splitting in best fit
jmasa@3732 57 ssize_t _bfr_surp; // surplus at start of current sweep
jmasa@3732 58 ssize_t _prev_sweep; // count from end of previous sweep
jmasa@3732 59 ssize_t _before_sweep; // count from before current sweep
jmasa@3732 60 ssize_t _coal_births; // additional chunks from coalescing
jmasa@3732 61 ssize_t _coal_deaths; // loss from coalescing
jmasa@3732 62 ssize_t _split_births; // additional chunks from splitting
jmasa@3732 63 ssize_t _split_deaths; // loss from splitting
jmasa@3732 64 size_t _returned_bytes; // number of bytes returned to list.
duke@435 65 public:
ysr@1580 66 void initialize(bool split_birth = false) {
duke@435 67 AdaptivePaddedAverage* dummy =
duke@435 68 new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight,
duke@435 69 CMS_FLSPadding);
duke@435 70 _desired = 0;
jmasa@3732 71 _coal_desired = 0;
duke@435 72 _surplus = 0;
jmasa@3732 73 _bfr_surp = 0;
jmasa@3732 74 _prev_sweep = 0;
jmasa@3732 75 _before_sweep = 0;
jmasa@3732 76 _coal_births = 0;
jmasa@3732 77 _coal_deaths = 0;
jmasa@3732 78 _split_births = (split_birth ? 1 : 0);
jmasa@3732 79 _split_deaths = 0;
jmasa@3732 80 _returned_bytes = 0;
duke@435 81 }
duke@435 82
duke@435 83 AllocationStats() {
duke@435 84 initialize();
duke@435 85 }
ysr@1580 86
duke@435 87 // The rate estimate is in blocks per second.
duke@435 88 void compute_desired(size_t count,
duke@435 89 float inter_sweep_current,
ysr@1580 90 float inter_sweep_estimate,
ysr@1580 91 float intra_sweep_estimate) {
duke@435 92 // If the latest inter-sweep time is below our granularity
duke@435 93 // of measurement, we may call in here with
duke@435 94 // inter_sweep_current == 0. However, even for suitably small
duke@435 95 // but non-zero inter-sweep durations, we may not trust the accuracy
duke@435 96 // of accumulated data, since it has not been "integrated"
duke@435 97 // (read "low-pass-filtered") long enough, and would be
duke@435 98 // vulnerable to noisy glitches. In such cases, we
duke@435 99 // ignore the current sample and use currently available
duke@435 100 // historical estimates.
jmasa@3732 101 assert(prev_sweep() + split_births() + coal_births() // "Total Production Stock"
jmasa@3732 102 >= split_deaths() + coal_deaths() + (ssize_t)count, // "Current stock + depletion"
ysr@2972 103 "Conservation Principle");
duke@435 104 if (inter_sweep_current > _threshold) {
jmasa@3732 105 ssize_t demand = prev_sweep() - (ssize_t)count + split_births() + coal_births()
jmasa@3732 106 - split_deaths() - coal_deaths();
ysr@2972 107 assert(demand >= 0,
ysr@2972 108 err_msg("Demand (" SSIZE_FORMAT ") should be non-negative for "
ysr@2972 109 PTR_FORMAT " (size=" SIZE_FORMAT ")",
drchase@6680 110 demand, p2i(this), count));
ysr@1580 111 // Defensive: adjust for imprecision in event counting
ysr@1580 112 if (demand < 0) {
ysr@1580 113 demand = 0;
ysr@1580 114 }
ysr@1580 115 float old_rate = _demand_rate_estimate.padded_average();
duke@435 116 float rate = ((float)demand)/inter_sweep_current;
duke@435 117 _demand_rate_estimate.sample(rate);
ysr@1580 118 float new_rate = _demand_rate_estimate.padded_average();
ysr@1580 119 ssize_t old_desired = _desired;
ysr@2502 120 float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
ysr@2502 121 _desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
ysr@1580 122 if (PrintFLSStatistics > 1) {
drchase@6680 123 gclog_or_tty->print_cr(
drchase@6680 124 "demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
drchase@6680 125 demand, old_rate, rate, new_rate, old_desired, _desired);
ysr@1580 126 }
duke@435 127 }
duke@435 128 }
duke@435 129
duke@435 130 ssize_t desired() const { return _desired; }
ysr@447 131 void set_desired(ssize_t v) { _desired = v; }
ysr@447 132
jmasa@3732 133 ssize_t coal_desired() const { return _coal_desired; }
jmasa@3732 134 void set_coal_desired(ssize_t v) { _coal_desired = v; }
duke@435 135
duke@435 136 ssize_t surplus() const { return _surplus; }
duke@435 137 void set_surplus(ssize_t v) { _surplus = v; }
duke@435 138 void increment_surplus() { _surplus++; }
duke@435 139 void decrement_surplus() { _surplus--; }
duke@435 140
jmasa@3732 141 ssize_t bfr_surp() const { return _bfr_surp; }
jmasa@3732 142 void set_bfr_surp(ssize_t v) { _bfr_surp = v; }
jmasa@3732 143 ssize_t prev_sweep() const { return _prev_sweep; }
jmasa@3732 144 void set_prev_sweep(ssize_t v) { _prev_sweep = v; }
jmasa@3732 145 ssize_t before_sweep() const { return _before_sweep; }
jmasa@3732 146 void set_before_sweep(ssize_t v) { _before_sweep = v; }
duke@435 147
jmasa@3732 148 ssize_t coal_births() const { return _coal_births; }
jmasa@3732 149 void set_coal_births(ssize_t v) { _coal_births = v; }
jmasa@3732 150 void increment_coal_births() { _coal_births++; }
duke@435 151
jmasa@3732 152 ssize_t coal_deaths() const { return _coal_deaths; }
jmasa@3732 153 void set_coal_deaths(ssize_t v) { _coal_deaths = v; }
jmasa@3732 154 void increment_coal_deaths() { _coal_deaths++; }
duke@435 155
jmasa@3732 156 ssize_t split_births() const { return _split_births; }
jmasa@3732 157 void set_split_births(ssize_t v) { _split_births = v; }
jmasa@3732 158 void increment_split_births() { _split_births++; }
duke@435 159
jmasa@3732 160 ssize_t split_deaths() const { return _split_deaths; }
jmasa@3732 161 void set_split_deaths(ssize_t v) { _split_deaths = v; }
jmasa@3732 162 void increment_split_deaths() { _split_deaths++; }
duke@435 163
duke@435 164 NOT_PRODUCT(
jmasa@3732 165 size_t returned_bytes() const { return _returned_bytes; }
jmasa@3732 166 void set_returned_bytes(size_t v) { _returned_bytes = v; }
duke@435 167 )
duke@435 168 };
stefank@2314 169
stefank@2314 170 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP

mercurial