< prev index next >

src/share/vm/gc/cms/allocationStats.hpp

Print this page




   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_CMS_ALLOCATIONSTATS_HPP
  26 #define SHARE_VM_GC_CMS_ALLOCATIONSTATS_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"

  29 #include "memory/allocation.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 class AllocationStats VALUE_OBJ_CLASS_SPEC {
  34   // A duration threshold (in ms) used to filter
  35   // possibly unreliable samples.
  36   static float _threshold;
  37 
  38   // We measure the demand between the end of the previous sweep and
  39   // beginning of this sweep:
  40   //   Count(end_last_sweep) - Count(start_this_sweep)
  41   //     + split_births(between) - split_deaths(between)
  42   // The above number divided by the time since the end of the
  43   // previous sweep gives us a time rate of demand for blocks
  44   // of this size. We compute a padded average of this rate as
  45   // our current estimate for the time rate of demand for blocks
  46   // of this size. Similarly, we keep a padded average for the time
  47   // between sweeps. Our current estimate for demand for blocks of
  48   // this size is then simply computed as the product of these two


 102            >= split_deaths() + coal_deaths() + (ssize_t)count, // "Current stock + depletion"
 103            "Conservation Principle");
 104     if (inter_sweep_current > _threshold) {
 105       ssize_t demand = prev_sweep() - (ssize_t)count + split_births() + coal_births()
 106                        - split_deaths() - coal_deaths();
 107       assert(demand >= 0,
 108              "Demand (" SSIZE_FORMAT ") should be non-negative for "
 109              PTR_FORMAT " (size=" SIZE_FORMAT ")",
 110              demand, p2i(this), count);
 111       // Defensive: adjust for imprecision in event counting
 112       if (demand < 0) {
 113         demand = 0;
 114       }
 115       float old_rate = _demand_rate_estimate.padded_average();
 116       float rate = ((float)demand)/inter_sweep_current;
 117       _demand_rate_estimate.sample(rate);
 118       float new_rate = _demand_rate_estimate.padded_average();
 119       ssize_t old_desired = _desired;
 120       float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
 121       _desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
 122       if (PrintFLSStatistics > 1) {
 123         gclog_or_tty->print_cr("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "
 124                                "new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
 125                                 demand, old_rate, rate, new_rate, old_desired, _desired);
 126       }
 127     }
 128   }
 129 
 130   ssize_t desired() const { return _desired; }
 131   void set_desired(ssize_t v) { _desired = v; }
 132 
 133   ssize_t coal_desired() const { return _coal_desired; }
 134   void set_coal_desired(ssize_t v) { _coal_desired = v; }
 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 
 141   ssize_t bfr_surp() const { return _bfr_surp; }
 142   void set_bfr_surp(ssize_t v) { _bfr_surp = v; }
 143   ssize_t prev_sweep() const { return _prev_sweep; }
 144   void set_prev_sweep(ssize_t v) { _prev_sweep = v; }
 145   ssize_t before_sweep() const { return _before_sweep; }
 146   void set_before_sweep(ssize_t v) { _before_sweep = v; }




   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_CMS_ALLOCATIONSTATS_HPP
  26 #define SHARE_VM_GC_CMS_ALLOCATIONSTATS_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"
  29 #include "logging/log.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "utilities/globalDefinitions.hpp"
  32 #include "utilities/macros.hpp"
  33 
  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)
  42   //     + split_births(between) - split_deaths(between)
  43   // The above number divided by the time since the end of the
  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


 103            >= split_deaths() + coal_deaths() + (ssize_t)count, // "Current stock + depletion"
 104            "Conservation Principle");
 105     if (inter_sweep_current > _threshold) {
 106       ssize_t demand = prev_sweep() - (ssize_t)count + split_births() + coal_births()
 107                        - split_deaths() - coal_deaths();
 108       assert(demand >= 0,
 109              "Demand (" SSIZE_FORMAT ") should be non-negative for "
 110              PTR_FORMAT " (size=" SIZE_FORMAT ")",
 111              demand, p2i(this), count);
 112       // Defensive: adjust for imprecision in event counting
 113       if (demand < 0) {
 114         demand = 0;
 115       }
 116       float old_rate = _demand_rate_estimate.padded_average();
 117       float rate = ((float)demand)/inter_sweep_current;
 118       _demand_rate_estimate.sample(rate);
 119       float new_rate = _demand_rate_estimate.padded_average();
 120       ssize_t old_desired = _desired;
 121       float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
 122       _desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
 123       log_trace(gc, freelist)("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "

 124                               "new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
 125                               demand, old_rate, rate, new_rate, old_desired, _desired);

 126     }
 127   }
 128 
 129   ssize_t desired() const { return _desired; }
 130   void set_desired(ssize_t v) { _desired = v; }
 131 
 132   ssize_t coal_desired() const { return _coal_desired; }
 133   void set_coal_desired(ssize_t v) { _coal_desired = v; }
 134 
 135   ssize_t surplus() const { return _surplus; }
 136   void set_surplus(ssize_t v) { _surplus = v; }
 137   void increment_surplus() { _surplus++; }
 138   void decrement_surplus() { _surplus--; }
 139 
 140   ssize_t bfr_surp() const { return _bfr_surp; }
 141   void set_bfr_surp(ssize_t v) { _bfr_surp = v; }
 142   ssize_t prev_sweep() const { return _prev_sweep; }
 143   void set_prev_sweep(ssize_t v) { _prev_sweep = v; }
 144   ssize_t before_sweep() const { return _before_sweep; }
 145   void set_before_sweep(ssize_t v) { _before_sweep = v; }


< prev index next >