< prev index next >

src/share/vm/gc_implementation/g1/g1MMUTracker.cpp

Print this page




   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  */
  24 
  25 #include "precompiled.hpp"

  26 #include "gc_implementation/g1/g1MMUTracker.hpp"
  27 #include "runtime/mutexLocker.hpp"
  28 #include "utilities/ostream.hpp"
  29 
  30 #define _DISABLE_MMU                             0
  31 
  32 // can't rely on comparing doubles with tolerating a small margin for error
  33 #define SMALL_MARGIN 0.0000001
  34 #define is_double_leq_0(_value) ( (_value) < SMALL_MARGIN )
  35 #define is_double_leq(_val1, _val2) is_double_leq_0((_val1) - (_val2))
  36 #define is_double_geq(_val1, _val2) is_double_leq_0((_val2) - (_val1))
  37 
  38 /***** ALL TIMES ARE IN SECS!!!!!!! *****/
  39 
  40 G1MMUTracker::G1MMUTracker(double time_slice, double max_gc_time) :
  41   _time_slice(time_slice),
  42   _max_gc_time(max_gc_time) { }
  43 
  44 G1MMUTrackerQueue::G1MMUTrackerQueue(double time_slice, double max_gc_time) :
  45   G1MMUTracker(time_slice, max_gc_time),


  88     //   increase the array size (:-)
  89     //   remove the oldest entry (this might allow more GC time for
  90     //     the time slice than what's allowed) - this is what we
  91     //     currently do
  92     //   consolidate the two entries with the minimum gap between them
  93     //     (this might allow less GC time than what's allowed)
  94 
  95     // In the case where ScavengeALot is true, such overflow is not
  96     // uncommon; in such cases, we can, without much loss of precision
  97     // or performance (we are GC'ing most of the time anyway!),
  98     // simply overwrite the oldest entry in the tracker.
  99 
 100     _head_index = trim_index(_head_index + 1);
 101     assert(_head_index == _tail_index, "Because we have a full circular buffer");
 102     _tail_index = trim_index(_tail_index + 1);
 103   } else {
 104     _head_index = trim_index(_head_index + 1);
 105     ++_no_entries;
 106   }
 107   _array[_head_index] = G1MMUTrackerQueueElem(start, end);



 108 }
 109 
 110 // basically the _internal call does not remove expired entries
 111 // this is for trying things out in the future and a couple
 112 // of other places (debugging)
 113 
 114 double G1MMUTrackerQueue::longest_pause(double current_time) {
 115   if (_DISABLE_MMU)
 116     return _max_gc_time;
 117 
 118   MutexLockerEx x(MMUTracker_lock, Mutex::_no_safepoint_check_flag);
 119   remove_expired_entries(current_time);
 120 
 121   return longest_pause_internal(current_time);
 122 }
 123 
 124 double G1MMUTrackerQueue::longest_pause_internal(double current_time) {
 125   double target_time = _max_gc_time;
 126 
 127   while( 1 ) {




   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  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/shared/gcTrace.hpp"
  27 #include "gc_implementation/g1/g1MMUTracker.hpp"
  28 #include "runtime/mutexLocker.hpp"
  29 #include "utilities/ostream.hpp"
  30 
  31 #define _DISABLE_MMU                             0
  32 
  33 // can't rely on comparing doubles with tolerating a small margin for error
  34 #define SMALL_MARGIN 0.0000001
  35 #define is_double_leq_0(_value) ( (_value) < SMALL_MARGIN )
  36 #define is_double_leq(_val1, _val2) is_double_leq_0((_val1) - (_val2))
  37 #define is_double_geq(_val1, _val2) is_double_leq_0((_val2) - (_val1))
  38 
  39 /***** ALL TIMES ARE IN SECS!!!!!!! *****/
  40 
  41 G1MMUTracker::G1MMUTracker(double time_slice, double max_gc_time) :
  42   _time_slice(time_slice),
  43   _max_gc_time(max_gc_time) { }
  44 
  45 G1MMUTrackerQueue::G1MMUTrackerQueue(double time_slice, double max_gc_time) :
  46   G1MMUTracker(time_slice, max_gc_time),


  89     //   increase the array size (:-)
  90     //   remove the oldest entry (this might allow more GC time for
  91     //     the time slice than what's allowed) - this is what we
  92     //     currently do
  93     //   consolidate the two entries with the minimum gap between them
  94     //     (this might allow less GC time than what's allowed)
  95 
  96     // In the case where ScavengeALot is true, such overflow is not
  97     // uncommon; in such cases, we can, without much loss of precision
  98     // or performance (we are GC'ing most of the time anyway!),
  99     // simply overwrite the oldest entry in the tracker.
 100 
 101     _head_index = trim_index(_head_index + 1);
 102     assert(_head_index == _tail_index, "Because we have a full circular buffer");
 103     _tail_index = trim_index(_tail_index + 1);
 104   } else {
 105     _head_index = trim_index(_head_index + 1);
 106     ++_no_entries;
 107   }
 108   _array[_head_index] = G1MMUTrackerQueueElem(start, end);
 109 
 110   double slice_time = calculate_gc_time(end);
 111   G1MMUTracer::report_mmu(_time_slice, slice_time, _max_gc_time);
 112 }
 113 
 114 // basically the _internal call does not remove expired entries
 115 // this is for trying things out in the future and a couple
 116 // of other places (debugging)
 117 
 118 double G1MMUTrackerQueue::longest_pause(double current_time) {
 119   if (_DISABLE_MMU)
 120     return _max_gc_time;
 121 
 122   MutexLockerEx x(MMUTracker_lock, Mutex::_no_safepoint_check_flag);
 123   remove_expired_entries(current_time);
 124 
 125   return longest_pause_internal(current_time);
 126 }
 127 
 128 double G1MMUTrackerQueue::longest_pause_internal(double current_time) {
 129   double target_time = _max_gc_time;
 130 
 131   while( 1 ) {


< prev index next >