< prev index next >

src/share/vm/gc/shared/plab.hpp

Print this page
rev 8816 : imported patch 8073013-add-detailed-information-about-plab-memory-usage


   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_SHARED_PLAB_HPP
  26 #define SHARE_VM_GC_SHARED_PLAB_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "runtime/atomic.hpp"
  31 #include "utilities/globalDefinitions.hpp"
  32 
  33 // Forward declarations.
  34 class PLABStats;
  35 
  36 // A per-thread allocation buffer used during GC.
  37 class PLAB: public CHeapObj<mtGC> {
  38 protected:
  39   char      head[32];
  40   size_t    _word_sz;          // In HeapWord units
  41   HeapWord* _bottom;
  42   HeapWord* _top;
  43   HeapWord* _end;           // Last allocatable address + 1
  44   HeapWord* _hard_end;      // _end + AlignmentReserve
  45   // In support of ergonomic sizing of PLAB's
  46   size_t    _allocated;     // in HeapWord units
  47   size_t    _wasted;        // in HeapWord units
  48   size_t    _undo_wasted;
  49   char      tail[32];
  50   static size_t AlignmentReserve;


 132     _hard_end = _bottom + word_sz();
 133     _end      = _hard_end - AlignmentReserve;
 134     assert(_end >= _top, "Negative buffer");
 135     // In support of ergonomic sizing
 136     _allocated += word_sz();
 137   }
 138 
 139   // Flush allocation statistics into the given PLABStats supporting ergonomic
 140   // sizing of PLAB's and retire the current buffer. To be called at the end of
 141   // GC.
 142   virtual void flush_and_retire_stats(PLABStats* stats);
 143 
 144   // Fills in the unallocated portion of the buffer with a garbage object and updates
 145   // statistics. To be called during GC.
 146   virtual void retire();
 147 
 148   void print() PRODUCT_RETURN;
 149 };
 150 
 151 // PLAB book-keeping.
 152 class PLABStats VALUE_OBJ_CLASS_SPEC {

 153   size_t _allocated;          // Total allocated
 154   size_t _wasted;             // of which wasted (internal fragmentation)
 155   size_t _undo_wasted;        // of which wasted on undo (is not used for calculation of PLAB size)
 156   size_t _unused;             // Unused in last buffer
 157   size_t _desired_net_plab_sz;// Output of filter (below), suitably trimmed and quantized
 158   AdaptiveWeightedAverage
 159          _filter;             // Integrator with decay
 160 
 161   void reset() {
 162     _allocated   = 0;
 163     _wasted      = 0;
 164     _undo_wasted = 0;
 165     _unused      = 0;
 166   }
 167  public:
 168   PLABStats(size_t desired_net_plab_sz_, unsigned wt) :
 169     _allocated(0),
 170     _wasted(0),
 171     _undo_wasted(0),
 172     _unused(0),
 173     _desired_net_plab_sz(desired_net_plab_sz_),
 174     _filter(wt)
 175   { }
 176 


 177   static const size_t min_size() {
 178     return PLAB::min_size();
 179   }
 180 
 181   static const size_t max_size() {
 182     return PLAB::max_size();
 183   }
 184 
 185   // Calculates plab size for current number of gc worker threads.
 186   size_t desired_plab_sz(uint no_of_gc_workers);
 187 
 188   // Updates the current desired PLAB size. Computes the new desired PLAB size with one gc worker thread,
 189   // updates _desired_plab_sz and clears sensor accumulators.
 190   void adjust_desired_plab_sz();
 191 
 192   void add_allocated(size_t v) {
 193     Atomic::add_ptr(v, &_allocated);
 194   }
 195 
 196   void add_unused(size_t v) {
 197     Atomic::add_ptr(v, &_unused);
 198   }
 199 
 200   void add_wasted(size_t v) {
 201     Atomic::add_ptr(v, &_wasted);
 202   }
 203 
 204   void add_undo_wasted(size_t v) {
 205     Atomic::add_ptr(v, &_undo_wasted);
 206   }
 207 };
 208 
 209 #endif // SHARE_VM_GC_SHARED_PLAB_HPP


   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_SHARED_PLAB_HPP
  26 #define SHARE_VM_GC_SHARED_PLAB_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "runtime/atomic.inline.hpp"
  31 #include "utilities/globalDefinitions.hpp"
  32 
  33 // Forward declarations.
  34 class PLABStats;
  35 
  36 // A per-thread allocation buffer used during GC.
  37 class PLAB: public CHeapObj<mtGC> {
  38 protected:
  39   char      head[32];
  40   size_t    _word_sz;          // In HeapWord units
  41   HeapWord* _bottom;
  42   HeapWord* _top;
  43   HeapWord* _end;           // Last allocatable address + 1
  44   HeapWord* _hard_end;      // _end + AlignmentReserve
  45   // In support of ergonomic sizing of PLAB's
  46   size_t    _allocated;     // in HeapWord units
  47   size_t    _wasted;        // in HeapWord units
  48   size_t    _undo_wasted;
  49   char      tail[32];
  50   static size_t AlignmentReserve;


 132     _hard_end = _bottom + word_sz();
 133     _end      = _hard_end - AlignmentReserve;
 134     assert(_end >= _top, "Negative buffer");
 135     // In support of ergonomic sizing
 136     _allocated += word_sz();
 137   }
 138 
 139   // Flush allocation statistics into the given PLABStats supporting ergonomic
 140   // sizing of PLAB's and retire the current buffer. To be called at the end of
 141   // GC.
 142   virtual void flush_and_retire_stats(PLABStats* stats);
 143 
 144   // Fills in the unallocated portion of the buffer with a garbage object and updates
 145   // statistics. To be called during GC.
 146   virtual void retire();
 147 
 148   void print() PRODUCT_RETURN;
 149 };
 150 
 151 // PLAB book-keeping.
 152 class PLABStats : public CHeapObj<mtGC> {
 153  protected:
 154   size_t _allocated;          // Total allocated
 155   size_t _wasted;             // of which wasted (internal fragmentation)
 156   size_t _undo_wasted;        // of which wasted on undo (is not used for calculation of PLAB size)
 157   size_t _unused;             // Unused in last buffer
 158   size_t _desired_net_plab_sz;// Output of filter (below), suitably trimmed and quantized
 159   AdaptiveWeightedAverage
 160          _filter;             // Integrator with decay
 161 
 162   virtual void reset() {
 163     _allocated   = 0;
 164     _wasted      = 0;
 165     _undo_wasted = 0;
 166     _unused      = 0;
 167   }
 168  public:
 169   PLABStats(size_t desired_net_plab_sz_, unsigned wt) :
 170     _allocated(0),
 171     _wasted(0),
 172     _undo_wasted(0),
 173     _unused(0),
 174     _desired_net_plab_sz(desired_net_plab_sz_),
 175     _filter(wt)
 176   { }
 177 
 178   virtual ~PLABStats() { }
 179 
 180   static const size_t min_size() {
 181     return PLAB::min_size();
 182   }
 183 
 184   static const size_t max_size() {
 185     return PLAB::max_size();
 186   }
 187 
 188   // Calculates plab size for current number of gc worker threads.
 189   size_t desired_plab_sz(uint no_of_gc_workers);
 190 
 191   // Updates the current desired PLAB size. Computes the new desired PLAB size with one gc worker thread,
 192   // updates _desired_plab_sz and clears sensor accumulators.
 193   virtual void adjust_desired_plab_sz();
 194 
 195   void add_allocated(size_t v) {
 196     Atomic::add_ptr(v, &_allocated);
 197   }
 198 
 199   void add_unused(size_t v) {
 200     Atomic::add_ptr(v, &_unused);
 201   }
 202 
 203   void add_wasted(size_t v) {
 204     Atomic::add_ptr(v, &_wasted);
 205   }
 206 
 207   void add_undo_wasted(size_t v) {
 208     Atomic::add_ptr(v, &_undo_wasted);
 209   }
 210 };
 211 
 212 #endif // SHARE_VM_GC_SHARED_PLAB_HPP
< prev index next >