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

Tue, 01 Feb 2011 10:02:01 -0800

author
ysr
date
Tue, 01 Feb 2011 10:02:01 -0800
changeset 2502
e49cfa28f585
parent 2314
f95d63e2154a
child 2708
1d1603768966
permissions
-rw-r--r--

6999988: CMS: Increased fragmentation leading to promotion failure after CR#6631166 got implemented
Summary: Fix calculation of _desired, in free list statistics, which was missing an intended set of parentheses.
Reviewed-by: poonam, jmasa

     1 /*
     2  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     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  *
    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  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP
    28 #ifndef SERIALGC
    29 #include "gc_implementation/shared/gcUtil.hpp"
    30 #include "memory/allocation.hpp"
    31 #include "utilities/globalDefinitions.hpp"
    32 #endif
    34 class AllocationStats VALUE_OBJ_CLASS_SPEC {
    35   // A duration threshold (in ms) used to filter
    36   // possibly unreliable samples.
    37   static float _threshold;
    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   //     + splitBirths(between) - splitDeaths(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
    50   // estimates.
    51   AdaptivePaddedAverage _demand_rate_estimate;
    53   ssize_t     _desired;         // Demand stimate computed as described above
    54   ssize_t     _coalDesired;     // desired +/- small-percent for tuning coalescing
    56   ssize_t     _surplus;         // count - (desired +/- small-percent),
    57                                 // used to tune splitting in best fit
    58   ssize_t     _bfrSurp;         // surplus at start of current sweep
    59   ssize_t     _prevSweep;       // count from end of previous sweep
    60   ssize_t     _beforeSweep;     // count from before current sweep
    61   ssize_t     _coalBirths;      // additional chunks from coalescing
    62   ssize_t     _coalDeaths;      // loss from coalescing
    63   ssize_t     _splitBirths;     // additional chunks from splitting
    64   ssize_t     _splitDeaths;     // loss from splitting
    65   size_t      _returnedBytes;   // number of bytes returned to list.
    66  public:
    67   void initialize(bool split_birth = false) {
    68     AdaptivePaddedAverage* dummy =
    69       new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight,
    70                                                          CMS_FLSPadding);
    71     _desired = 0;
    72     _coalDesired = 0;
    73     _surplus = 0;
    74     _bfrSurp = 0;
    75     _prevSweep = 0;
    76     _beforeSweep = 0;
    77     _coalBirths = 0;
    78     _coalDeaths = 0;
    79     _splitBirths = split_birth? 1 : 0;
    80     _splitDeaths = 0;
    81     _returnedBytes = 0;
    82   }
    84   AllocationStats() {
    85     initialize();
    86   }
    88   // The rate estimate is in blocks per second.
    89   void compute_desired(size_t count,
    90                        float inter_sweep_current,
    91                        float inter_sweep_estimate,
    92                        float intra_sweep_estimate) {
    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.
   102     // XXX NEEDS TO BE FIXED
   103     // assert(prevSweep() + splitBirths() >= splitDeaths() + (ssize_t)count, "Conservation Principle");
   104     //     ^^^^^^^^^^^^^^^^^^^^^^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   105     //     "Total Stock"                  "Not used at this block size"
   106     if (inter_sweep_current > _threshold) {
   107       ssize_t demand = prevSweep() - (ssize_t)count + splitBirths() - splitDeaths();
   108       // XXX NEEDS TO BE FIXED
   109       // assert(demand >= 0, "Demand should be non-negative");
   110       // Defensive: adjust for imprecision in event counting
   111       if (demand < 0) {
   112         demand = 0;
   113       }
   114       float old_rate = _demand_rate_estimate.padded_average();
   115       float rate = ((float)demand)/inter_sweep_current;
   116       _demand_rate_estimate.sample(rate);
   117       float new_rate = _demand_rate_estimate.padded_average();
   118       ssize_t old_desired = _desired;
   119       float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
   120       _desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
   121       if (PrintFLSStatistics > 1) {
   122         gclog_or_tty->print_cr("demand: %d, old_rate: %f, current_rate: %f, new_rate: %f, old_desired: %d, new_desired: %d",
   123                                 demand,     old_rate,     rate,             new_rate,     old_desired,     _desired);
   124       }
   125     }
   126   }
   128   ssize_t desired() const { return _desired; }
   129   void set_desired(ssize_t v) { _desired = v; }
   131   ssize_t coalDesired() const { return _coalDesired; }
   132   void set_coalDesired(ssize_t v) { _coalDesired = v; }
   134   ssize_t surplus() const { return _surplus; }
   135   void set_surplus(ssize_t v) { _surplus = v; }
   136   void increment_surplus() { _surplus++; }
   137   void decrement_surplus() { _surplus--; }
   139   ssize_t bfrSurp() const { return _bfrSurp; }
   140   void set_bfrSurp(ssize_t v) { _bfrSurp = v; }
   141   ssize_t prevSweep() const { return _prevSweep; }
   142   void set_prevSweep(ssize_t v) { _prevSweep = v; }
   143   ssize_t beforeSweep() const { return _beforeSweep; }
   144   void set_beforeSweep(ssize_t v) { _beforeSweep = v; }
   146   ssize_t coalBirths() const { return _coalBirths; }
   147   void set_coalBirths(ssize_t v) { _coalBirths = v; }
   148   void increment_coalBirths() { _coalBirths++; }
   150   ssize_t coalDeaths() const { return _coalDeaths; }
   151   void set_coalDeaths(ssize_t v) { _coalDeaths = v; }
   152   void increment_coalDeaths() { _coalDeaths++; }
   154   ssize_t splitBirths() const { return _splitBirths; }
   155   void set_splitBirths(ssize_t v) { _splitBirths = v; }
   156   void increment_splitBirths() { _splitBirths++; }
   158   ssize_t splitDeaths() const { return _splitDeaths; }
   159   void set_splitDeaths(ssize_t v) { _splitDeaths = v; }
   160   void increment_splitDeaths() { _splitDeaths++; }
   162   NOT_PRODUCT(
   163     size_t returnedBytes() const { return _returnedBytes; }
   164     void set_returnedBytes(size_t v) { _returnedBytes = v; }
   165   )
   166 };
   168 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_ALLOCATIONSTATS_HPP

mercurial