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

Print this page


   1 /*
   2  * Copyright (c) 2001, 2016, 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  *


 137 // Calculates plab size for current number of gc worker threads.
 138 size_t PLABStats::desired_plab_sz(uint no_of_gc_workers) {
 139   return (size_t)align_object_size(MIN2(MAX2(min_size(), _desired_net_plab_sz / no_of_gc_workers), max_size()));
 140 }
 141 
 142 // Compute desired plab size for one gc worker thread and latch result for later
 143 // use. This should be called once at the end of parallel
 144 // scavenge; it clears the sensor accumulators.
 145 void PLABStats::adjust_desired_plab_sz() {
 146   log_plab_allocation();
 147 
 148   if (!ResizePLAB) {
 149     // Clear accumulators for next round.
 150     reset();
 151     return;
 152   }
 153 
 154   assert(is_object_aligned(max_size()) && min_size() <= max_size(),
 155          "PLAB clipping computation may be incorrect");
 156 
 157   if (_allocated == 0) {
 158     assert(_unused == 0,
 159            "Inconsistency in PLAB stats: "
 160            "_allocated: " SIZE_FORMAT ", "
 161            "_wasted: " SIZE_FORMAT ", "
 162            "_unused: " SIZE_FORMAT ", "
 163            "_undo_wasted: " SIZE_FORMAT,
 164            _allocated, _wasted, _unused, _undo_wasted);
 165 
 166     _allocated = 1;
 167   }
 168   double wasted_frac    = (double)_unused / (double)_allocated;










 169   size_t target_refills = (size_t)((wasted_frac * TargetSurvivorRatio) / TargetPLABWastePct);
 170   if (target_refills == 0) {
 171     target_refills = 1;
 172   }
 173   size_t used = _allocated - _wasted - _unused;
 174   // Assumed to have 1 gc worker thread
 175   size_t recent_plab_sz = used / target_refills;
 176   // Take historical weighted average
 177   _filter.sample(recent_plab_sz);
 178   _desired_net_plab_sz = MAX2(min_size(), (size_t)_filter.average());
 179 
 180   log_sizing(recent_plab_sz, _desired_net_plab_sz);
 181 
 182   reset();
 183 }
   1 /*
   2  * Copyright (c) 2001, 2017, 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  *


 137 // Calculates plab size for current number of gc worker threads.
 138 size_t PLABStats::desired_plab_sz(uint no_of_gc_workers) {
 139   return (size_t)align_object_size(MIN2(MAX2(min_size(), _desired_net_plab_sz / no_of_gc_workers), max_size()));
 140 }
 141 
 142 // Compute desired plab size for one gc worker thread and latch result for later
 143 // use. This should be called once at the end of parallel
 144 // scavenge; it clears the sensor accumulators.
 145 void PLABStats::adjust_desired_plab_sz() {
 146   log_plab_allocation();
 147 
 148   if (!ResizePLAB) {
 149     // Clear accumulators for next round.
 150     reset();
 151     return;
 152   }
 153 
 154   assert(is_object_aligned(max_size()) && min_size() <= max_size(),
 155          "PLAB clipping computation may be incorrect");
 156 
 157   assert(_allocated != 0 || _unused == 0,

 158          "Inconsistency in PLAB stats: "
 159          "_allocated: " SIZE_FORMAT ", "
 160          "_wasted: " SIZE_FORMAT ", "
 161          "_unused: " SIZE_FORMAT ", "
 162          "_undo_wasted: " SIZE_FORMAT,
 163          _allocated, _wasted, _unused, _undo_wasted);
 164 
 165   size_t plab_sz = compute_desired_plab_sz();
 166   // Take historical weighted average
 167   _filter.sample(plab_sz);
 168   _desired_net_plab_sz = MAX2(min_size(), (size_t)_filter.average());
 169 
 170   log_sizing(plab_sz, _desired_net_plab_sz);
 171   // Clear accumulators for next round
 172   reset();
 173 }
 174 
 175 size_t PLABStats::compute_desired_plab_sz() {
 176   size_t allocated = MAX2(_allocated, size_t(1));
 177   double wasted_frac    = (double)_unused / (double)allocated;
 178   size_t target_refills = (size_t)((wasted_frac * TargetSurvivorRatio) / TargetPLABWastePct);
 179   if (target_refills == 0) {
 180     target_refills = 1;
 181   }
 182   size_t used = allocated - _wasted - _unused;
 183   // Assumed to have 1 gc worker thread
 184   size_t recent_plab_sz = used / target_refills;
 185   return recent_plab_sz;






 186 }