src/share/vm/gc_implementation/shared/coTracker.cpp

changeset 1372
ead53f6b615d
parent 1370
05f89f00a864
parent 1371
e1fdf4fd34dc
child 1373
b37c246bf7ce
     1.1 --- a/src/share/vm/gc_implementation/shared/coTracker.cpp	Mon Aug 24 10:36:31 2009 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,189 +0,0 @@
     1.4 -/*
     1.5 - * Copyright 2001-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - *
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - *
    1.22 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 - * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 - * have any questions.
    1.25 - *
    1.26 - */
    1.27 -
    1.28 -# include "incls/_precompiled.incl"
    1.29 -# include "incls/_coTracker.cpp.incl"
    1.30 -
    1.31 -COTracker* COTracker::_head = NULL;
    1.32 -double COTracker::_cpu_number = -1.0;
    1.33 -
    1.34 -void
    1.35 -COTracker::resetPeriod(double now_sec, double vnow_sec) {
    1.36 -  guarantee( _enabled, "invariant" );
    1.37 -  _period_start_time_sec  = now_sec;
    1.38 -  _period_start_vtime_sec = vnow_sec;
    1.39 -}
    1.40 -
    1.41 -void
    1.42 -COTracker::setConcOverhead(double time_stamp_sec,
    1.43 -                           double conc_overhead) {
    1.44 -  guarantee( _enabled, "invariant" );
    1.45 -  _conc_overhead  = conc_overhead;
    1.46 -  _time_stamp_sec = time_stamp_sec;
    1.47 -  if (conc_overhead > 0.001)
    1.48 -    _conc_overhead_seq.add(conc_overhead);
    1.49 -}
    1.50 -
    1.51 -void
    1.52 -COTracker::reset(double starting_conc_overhead) {
    1.53 -  guarantee( _enabled, "invariant" );
    1.54 -  double now_sec = os::elapsedTime();
    1.55 -  setConcOverhead(now_sec, starting_conc_overhead);
    1.56 -}
    1.57 -
    1.58 -void
    1.59 -COTracker::start() {
    1.60 -  guarantee( _enabled, "invariant" );
    1.61 -  resetPeriod(os::elapsedTime(), os::elapsedVTime());
    1.62 -}
    1.63 -
    1.64 -void
    1.65 -COTracker::update(bool force_end) {
    1.66 -  assert( _enabled, "invariant" );
    1.67 -  double end_time_sec = os::elapsedTime();
    1.68 -  double elapsed_time_sec = end_time_sec - _period_start_time_sec;
    1.69 -  if (force_end || elapsed_time_sec > _update_period_sec) {
    1.70 -    // reached the end of the period
    1.71 -    double end_vtime_sec = os::elapsedVTime();
    1.72 -    double elapsed_vtime_sec = end_vtime_sec - _period_start_vtime_sec;
    1.73 -
    1.74 -    double conc_overhead = elapsed_vtime_sec / elapsed_time_sec;
    1.75 -
    1.76 -    setConcOverhead(end_time_sec, conc_overhead);
    1.77 -    resetPeriod(end_time_sec, end_vtime_sec);
    1.78 -  }
    1.79 -}
    1.80 -
    1.81 -void
    1.82 -COTracker::updateForSTW(double start_sec, double end_sec) {
    1.83 -  if (!_enabled)
    1.84 -    return;
    1.85 -
    1.86 -  // During a STW pause, no concurrent GC thread has done any
    1.87 -  // work. So, we can safely adjust the start of the current period by
    1.88 -  // adding the duration of the STW pause to it, so that the STW pause
    1.89 -  // doesn't affect the reading of the concurrent overhead (it's
    1.90 -  // basically like excluding the time of the STW pause from the
    1.91 -  // concurrent overhead calculation).
    1.92 -
    1.93 -  double stw_duration_sec = end_sec - start_sec;
    1.94 -  guarantee( stw_duration_sec > 0.0, "invariant" );
    1.95 -
    1.96 -  if (outOfDate(start_sec))
    1.97 -    _conc_overhead = 0.0;
    1.98 -  else
    1.99 -    _time_stamp_sec = end_sec;
   1.100 -  _period_start_time_sec += stw_duration_sec;
   1.101 -  _conc_overhead_seq = NumberSeq();
   1.102 -
   1.103 -  guarantee( os::elapsedTime() > _period_start_time_sec, "invariant" );
   1.104 -}
   1.105 -
   1.106 -double
   1.107 -COTracker::predConcOverhead() {
   1.108 -  if (_enabled) {
   1.109 -    // tty->print(" %1.2lf", _conc_overhead_seq.maximum());
   1.110 -    return _conc_overhead_seq.maximum();
   1.111 -  } else {
   1.112 -    // tty->print(" DD");
   1.113 -    return 0.0;
   1.114 -  }
   1.115 -}
   1.116 -
   1.117 -void
   1.118 -COTracker::resetPred() {
   1.119 -  _conc_overhead_seq = NumberSeq();
   1.120 -}
   1.121 -
   1.122 -COTracker::COTracker(int group)
   1.123 -    : _enabled(false),
   1.124 -      _group(group),
   1.125 -      _period_start_time_sec(-1.0),
   1.126 -      _period_start_vtime_sec(-1.0),
   1.127 -      _conc_overhead(-1.0),
   1.128 -      _time_stamp_sec(-1.0),
   1.129 -      _next(NULL) {
   1.130 -  // GCOverheadReportingPeriodMS indicates how frequently the
   1.131 -  // concurrent overhead will be recorded by the GC Overhead
   1.132 -  // Reporter. We want to take readings less often than that. If we
   1.133 -  // took readings more often than some of them might be lost.
   1.134 -  _update_period_sec = ((double) GCOverheadReportingPeriodMS) / 1000.0 * 1.25;
   1.135 -  _next = _head;
   1.136 -  _head = this;
   1.137 -
   1.138 -  if (_cpu_number < 0.0)
   1.139 -    _cpu_number = (double) os::processor_count();
   1.140 -}
   1.141 -
   1.142 -// statics
   1.143 -
   1.144 -void
   1.145 -COTracker::updateAllForSTW(double start_sec, double end_sec) {
   1.146 -  for (COTracker* curr = _head; curr != NULL; curr = curr->_next) {
   1.147 -    curr->updateForSTW(start_sec, end_sec);
   1.148 -  }
   1.149 -}
   1.150 -
   1.151 -double
   1.152 -COTracker::totalConcOverhead(double now_sec) {
   1.153 -  double total_conc_overhead = 0.0;
   1.154 -
   1.155 -  for (COTracker* curr = _head; curr != NULL; curr = curr->_next) {
   1.156 -    double conc_overhead = curr->concOverhead(now_sec);
   1.157 -    total_conc_overhead += conc_overhead;
   1.158 -  }
   1.159 -
   1.160 -  return total_conc_overhead;
   1.161 -}
   1.162 -
   1.163 -double
   1.164 -COTracker::totalConcOverhead(double now_sec,
   1.165 -                             size_t group_num,
   1.166 -                             double* co_per_group) {
   1.167 -  double total_conc_overhead = 0.0;
   1.168 -
   1.169 -  for (size_t i = 0; i < group_num; ++i)
   1.170 -    co_per_group[i] = 0.0;
   1.171 -
   1.172 -  for (COTracker* curr = _head; curr != NULL; curr = curr->_next) {
   1.173 -    size_t group = curr->_group;
   1.174 -    assert( 0 <= group && group < group_num, "invariant" );
   1.175 -    double conc_overhead = curr->concOverhead(now_sec);
   1.176 -
   1.177 -    co_per_group[group] += conc_overhead;
   1.178 -    total_conc_overhead += conc_overhead;
   1.179 -  }
   1.180 -
   1.181 -  return total_conc_overhead;
   1.182 -}
   1.183 -
   1.184 -double
   1.185 -COTracker::totalPredConcOverhead() {
   1.186 -  double total_pred_conc_overhead = 0.0;
   1.187 -  for (COTracker* curr = _head; curr != NULL; curr = curr->_next) {
   1.188 -    total_pred_conc_overhead += curr->predConcOverhead();
   1.189 -    curr->resetPred();
   1.190 -  }
   1.191 -  return total_pred_conc_overhead / _cpu_number;
   1.192 -}

mercurial