< prev index next >

src/hotspot/share/gc/g1/g1MMUTracker.cpp

Print this page
rev 59204 : imported patch 8244815-sjohanss-review
   1 /*
   2  * Copyright (c) 2001, 2019, 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  *


  90     //     (this might allow less GC time than what's allowed)
  91 
  92     // In the case where ScavengeALot is true, such overflow is not
  93     // uncommon; in such cases, we can, without much loss of precision
  94     // or performance (we are GC'ing most of the time anyway!),
  95     // simply overwrite the oldest entry in the tracker.
  96 
  97     _head_index = trim_index(_head_index + 1);
  98     assert(_head_index == _tail_index, "Because we have a full circular buffer");
  99     _tail_index = trim_index(_tail_index + 1);
 100   } else {
 101     _head_index = trim_index(_head_index + 1);
 102     ++_no_entries;
 103   }
 104   _array[_head_index] = G1MMUTrackerQueueElem(start, end);
 105 
 106   // Current entry needs to be added before calculating the value
 107   double slice_time = calculate_gc_time(end);
 108   G1MMUTracer::report_mmu(_time_slice, slice_time, _max_gc_time);
 109 
 110   if (slice_time >= _max_gc_time) {
 111     log_info(gc, mmu)("MMU target violated: %.1lfms (%.1lfms/%.1lfms)", slice_time * 1000.0, _max_gc_time * 1000.0, _time_slice * 1000);




 112   }
 113 }
 114 
 115 double G1MMUTrackerQueue::when_sec(double current_time, double pause_time) {
 116   // if the pause is over the maximum, just assume that it's the maximum
 117   double adjusted_pause_time =
 118     (pause_time > max_gc_time()) ? max_gc_time() : pause_time;
 119   double earliest_end = current_time + adjusted_pause_time;
 120   double limit = earliest_end - _time_slice;
 121   double gc_time = calculate_gc_time(earliest_end);
 122   double diff = gc_time + adjusted_pause_time - max_gc_time();
 123   if (is_double_leq_0(diff))
 124     return 0.0;
 125 
 126   int index = _tail_index;
 127   while ( 1 ) {
 128     G1MMUTrackerQueueElem *elem = &_array[index];
 129     if (elem->end_time() > limit) {
 130       if (elem->start_time() > limit)
 131         diff -= elem->duration();
   1 /*
   2  * Copyright (c) 2001, 2020, 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  *


  90     //     (this might allow less GC time than what's allowed)
  91 
  92     // In the case where ScavengeALot is true, such overflow is not
  93     // uncommon; in such cases, we can, without much loss of precision
  94     // or performance (we are GC'ing most of the time anyway!),
  95     // simply overwrite the oldest entry in the tracker.
  96 
  97     _head_index = trim_index(_head_index + 1);
  98     assert(_head_index == _tail_index, "Because we have a full circular buffer");
  99     _tail_index = trim_index(_tail_index + 1);
 100   } else {
 101     _head_index = trim_index(_head_index + 1);
 102     ++_no_entries;
 103   }
 104   _array[_head_index] = G1MMUTrackerQueueElem(start, end);
 105 
 106   // Current entry needs to be added before calculating the value
 107   double slice_time = calculate_gc_time(end);
 108   G1MMUTracer::report_mmu(_time_slice, slice_time, _max_gc_time);
 109 
 110   if (slice_time < _max_gc_time) {
 111     log_debug(gc, mmu)("MMU: %.1lfms (%.1lfms/%.1lfms)",
 112                        slice_time * 1000.0, _max_gc_time * 1000.0, _time_slice * 1000);
 113   } else {
 114     log_info(gc, mmu)("MMU target violated: %.1lfms (%.1lfms/%.1lfms)",
 115                       slice_time * 1000.0, _max_gc_time * 1000.0, _time_slice * 1000);
 116   }
 117 }
 118 
 119 double G1MMUTrackerQueue::when_sec(double current_time, double pause_time) {
 120   // if the pause is over the maximum, just assume that it's the maximum
 121   double adjusted_pause_time =
 122     (pause_time > max_gc_time()) ? max_gc_time() : pause_time;
 123   double earliest_end = current_time + adjusted_pause_time;
 124   double limit = earliest_end - _time_slice;
 125   double gc_time = calculate_gc_time(earliest_end);
 126   double diff = gc_time + adjusted_pause_time - max_gc_time();
 127   if (is_double_leq_0(diff))
 128     return 0.0;
 129 
 130   int index = _tail_index;
 131   while ( 1 ) {
 132     G1MMUTrackerQueueElem *elem = &_array[index];
 133     if (elem->end_time() > limit) {
 134       if (elem->start_time() > limit)
 135         diff -= elem->duration();
< prev index next >