< prev index next >

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

Print this page
rev 7854 : imported patch 8027962-per-phase-timing-measurements-for-strong-roots-processing
rev 7855 : [mq]: 8027962-bengt-suggestions
   1 /*
   2  * Copyright (c) 2013, 2014 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  */
  24 
  25 
  26 #include "precompiled.hpp"
  27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
  29 #include "gc_implementation/g1/g1Log.hpp"
  30 #include "gc_implementation/g1/g1StringDedup.hpp"
  31 #include "runtime/atomic.inline.hpp"
  32 #include "g1CollectedHeap.hpp"
  33 
  34 // Helper class for avoiding interleaved logging
  35 class LineBuffer: public StackObj {
  36 
  37 private:
  38   static const int BUFFER_LEN = 1024;
  39   static const int INDENT_CHARS = 3;
  40   char _buffer[BUFFER_LEN];
  41   int _indent_level;
  42   int _cur;
  43 
  44   void vappend(const char* format, va_list ap)  ATTRIBUTE_PRINTF(2, 0) {
  45     int res = vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
  46     if (res != -1) {
  47       _cur += res;
  48     } else {
  49       DEBUG_ONLY(warning("buffer too small in LineBuffer");)
  50       _buffer[BUFFER_LEN -1] = 0;
  51       _cur = BUFFER_LEN; // vsnprintf above should not add to _buffer if we are called again
  52     }


 129     // for things like the start and end times the sum is not
 130     // that relevant
 131     buf.append(", Sum: ");
 132     buf.append(_print_format, sum);
 133   }
 134   buf.append_and_print_cr("]");
 135 }
 136 PRAGMA_DIAG_POP
 137 
 138 #ifndef PRODUCT
 139 
 140 template <> const int WorkerDataArray<int>::_uninitialized = -1;
 141 template <> const double WorkerDataArray<double>::_uninitialized = -1.0;
 142 template <> const size_t WorkerDataArray<size_t>::_uninitialized = (size_t)-1;
 143 
 144 template <class T>
 145 void WorkerDataArray<T>::reset() {
 146   for (uint i = 0; i < _length; i++) {
 147     _data[i] = (T)_uninitialized;
 148   }
 149   _has_new_data = true;
 150 }
 151 
 152 template <class T>
 153 void WorkerDataArray<T>::verify() {
 154   for (uint i = 0; i < _length; i++) {
 155     assert(_data[i] != _uninitialized,
 156         err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
 157             i, (double)_data[i], (double)_uninitialized));
 158   }
 159 }
 160 
 161 #endif
 162 
 163 G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads, uint num_ext_root_scan_phases) :
 164   _max_gc_threads(max_gc_threads),
 165   _num_ext_root_scan_phases(num_ext_root_scan_phases),
 166   _last_gc_worker_start_times_ms(_max_gc_threads, "%.1lf", false),
 167   _last_ext_root_scan_times_ms(_max_gc_threads, "%.1lf"),
 168   _last_ext_root_scan_phase_times_ms(NULL),
 169   _last_satb_filtering_times_ms(_max_gc_threads, "%.1lf"),


   1 /*
   2  * Copyright (c) 2013, 2015 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  */
  24 
  25 
  26 #include "precompiled.hpp"
  27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  28 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
  29 #include "gc_implementation/g1/g1Log.hpp"
  30 #include "gc_implementation/g1/g1StringDedup.hpp"
  31 #include "runtime/atomic.inline.hpp"

  32 
  33 // Helper class for avoiding interleaved logging
  34 class LineBuffer: public StackObj {
  35 
  36 private:
  37   static const int BUFFER_LEN = 1024;
  38   static const int INDENT_CHARS = 3;
  39   char _buffer[BUFFER_LEN];
  40   int _indent_level;
  41   int _cur;
  42 
  43   void vappend(const char* format, va_list ap)  ATTRIBUTE_PRINTF(2, 0) {
  44     int res = vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
  45     if (res != -1) {
  46       _cur += res;
  47     } else {
  48       DEBUG_ONLY(warning("buffer too small in LineBuffer");)
  49       _buffer[BUFFER_LEN -1] = 0;
  50       _cur = BUFFER_LEN; // vsnprintf above should not add to _buffer if we are called again
  51     }


 128     // for things like the start and end times the sum is not
 129     // that relevant
 130     buf.append(", Sum: ");
 131     buf.append(_print_format, sum);
 132   }
 133   buf.append_and_print_cr("]");
 134 }
 135 PRAGMA_DIAG_POP
 136 
 137 #ifndef PRODUCT
 138 
 139 template <> const int WorkerDataArray<int>::_uninitialized = -1;
 140 template <> const double WorkerDataArray<double>::_uninitialized = -1.0;
 141 template <> const size_t WorkerDataArray<size_t>::_uninitialized = (size_t)-1;
 142 
 143 template <class T>
 144 void WorkerDataArray<T>::reset() {
 145   for (uint i = 0; i < _length; i++) {
 146     _data[i] = (T)_uninitialized;
 147   }

 148 }
 149 
 150 template <class T>
 151 void WorkerDataArray<T>::verify() {
 152   for (uint i = 0; i < _length; i++) {
 153     assert(_data[i] != _uninitialized,
 154         err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
 155             i, (double)_data[i], (double)_uninitialized));
 156   }
 157 }
 158 
 159 #endif
 160 
 161 G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads, uint num_ext_root_scan_phases) :
 162   _max_gc_threads(max_gc_threads),
 163   _num_ext_root_scan_phases(num_ext_root_scan_phases),
 164   _last_gc_worker_start_times_ms(_max_gc_threads, "%.1lf", false),
 165   _last_ext_root_scan_times_ms(_max_gc_threads, "%.1lf"),
 166   _last_ext_root_scan_phase_times_ms(NULL),
 167   _last_satb_filtering_times_ms(_max_gc_threads, "%.1lf"),


< prev index next >