1.1 --- a/src/share/vm/gc_implementation/shared/gcOverheadReporter.cpp Fri Aug 14 13:44:15 2009 -0700 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,179 +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/_gcOverheadReporter.cpp.incl" 1.30 - 1.31 -class COReportingThread : public ConcurrentGCThread { 1.32 -private: 1.33 - GCOverheadReporter* _reporter; 1.34 - 1.35 -public: 1.36 - COReportingThread(GCOverheadReporter* reporter) : _reporter(reporter) { 1.37 - guarantee( _reporter != NULL, "precondition" ); 1.38 - create_and_start(); 1.39 - } 1.40 - 1.41 - virtual void run() { 1.42 - initialize_in_thread(); 1.43 - wait_for_universe_init(); 1.44 - 1.45 - int period_ms = GCOverheadReportingPeriodMS; 1.46 - 1.47 - while ( true ) { 1.48 - os::sleep(Thread::current(), period_ms, false); 1.49 - 1.50 - _sts.join(); 1.51 - double now_sec = os::elapsedTime(); 1.52 - _reporter->collect_and_record_conc_overhead(now_sec); 1.53 - _sts.leave(); 1.54 - } 1.55 - 1.56 - terminate(); 1.57 - } 1.58 -}; 1.59 - 1.60 -GCOverheadReporter* GCOverheadReporter::_reporter = NULL; 1.61 - 1.62 -GCOverheadReporter::GCOverheadReporter(size_t group_num, 1.63 - const char* group_names[], 1.64 - size_t length) 1.65 - : _group_num(group_num), _prev_end_sec(0.0) { 1.66 - guarantee( 0 <= group_num && group_num <= MaxGCOverheadGroupNum, 1.67 - "precondition" ); 1.68 - 1.69 - _base = NEW_C_HEAP_ARRAY(GCOverheadReporterEntry, length); 1.70 - _top = _base + length; 1.71 - _curr = _base; 1.72 - 1.73 - for (size_t i = 0; i < group_num; ++i) { 1.74 - guarantee( group_names[i] != NULL, "precondition" ); 1.75 - _group_names[i] = group_names[i]; 1.76 - } 1.77 -} 1.78 - 1.79 -void 1.80 -GCOverheadReporter::add(double start_sec, double end_sec, 1.81 - double* conc_overhead, 1.82 - double stw_overhead) { 1.83 - assert( _curr <= _top, "invariant" ); 1.84 - 1.85 - if (_curr == _top) { 1.86 - guarantee( false, "trace full" ); 1.87 - return; 1.88 - } 1.89 - 1.90 - _curr->_start_sec = start_sec; 1.91 - _curr->_end_sec = end_sec; 1.92 - for (size_t i = 0; i < _group_num; ++i) { 1.93 - _curr->_conc_overhead[i] = 1.94 - (conc_overhead != NULL) ? conc_overhead[i] : 0.0; 1.95 - } 1.96 - _curr->_stw_overhead = stw_overhead; 1.97 - 1.98 - ++_curr; 1.99 -} 1.100 - 1.101 -void 1.102 -GCOverheadReporter::collect_and_record_conc_overhead(double end_sec) { 1.103 - double start_sec = _prev_end_sec; 1.104 - guarantee( end_sec > start_sec, "invariant" ); 1.105 - 1.106 - double conc_overhead[MaxGCOverheadGroupNum]; 1.107 - COTracker::totalConcOverhead(end_sec, _group_num, conc_overhead); 1.108 - add_conc_overhead(start_sec, end_sec, conc_overhead); 1.109 - _prev_end_sec = end_sec; 1.110 -} 1.111 - 1.112 -void 1.113 -GCOverheadReporter::record_stw_start(double start_sec) { 1.114 - guarantee( start_sec > _prev_end_sec, "invariant" ); 1.115 - collect_and_record_conc_overhead(start_sec); 1.116 -} 1.117 - 1.118 -void 1.119 -GCOverheadReporter::record_stw_end(double end_sec) { 1.120 - double start_sec = _prev_end_sec; 1.121 - COTracker::updateAllForSTW(start_sec, end_sec); 1.122 - add_stw_overhead(start_sec, end_sec, 1.0); 1.123 - 1.124 - _prev_end_sec = end_sec; 1.125 -} 1.126 - 1.127 -void 1.128 -GCOverheadReporter::print() const { 1.129 - tty->print_cr(""); 1.130 - tty->print_cr("GC Overhead (%d entries)", _curr - _base); 1.131 - tty->print_cr(""); 1.132 - GCOverheadReporterEntry* curr = _base; 1.133 - while (curr < _curr) { 1.134 - double total = curr->_stw_overhead; 1.135 - for (size_t i = 0; i < _group_num; ++i) 1.136 - total += curr->_conc_overhead[i]; 1.137 - 1.138 - tty->print("OVERHEAD %12.8lf %12.8lf ", 1.139 - curr->_start_sec, curr->_end_sec); 1.140 - 1.141 - for (size_t i = 0; i < _group_num; ++i) 1.142 - tty->print("%s %12.8lf ", _group_names[i], curr->_conc_overhead[i]); 1.143 - 1.144 - tty->print_cr("STW %12.8lf TOT %12.8lf", curr->_stw_overhead, total); 1.145 - ++curr; 1.146 - } 1.147 - tty->print_cr(""); 1.148 -} 1.149 - 1.150 -// statics 1.151 - 1.152 -void 1.153 -GCOverheadReporter::initGCOverheadReporter(size_t group_num, 1.154 - const char* group_names[]) { 1.155 - guarantee( _reporter == NULL, "should only be called once" ); 1.156 - guarantee( 0 <= group_num && group_num <= MaxGCOverheadGroupNum, 1.157 - "precondition" ); 1.158 - guarantee( group_names != NULL, "pre-condition" ); 1.159 - 1.160 - if (GCOverheadReporting) { 1.161 - _reporter = new GCOverheadReporter(group_num, group_names); 1.162 - new COReportingThread(_reporter); 1.163 - } 1.164 -} 1.165 - 1.166 -void 1.167 -GCOverheadReporter::recordSTWStart(double start_sec) { 1.168 - if (_reporter != NULL) 1.169 - _reporter->record_stw_start(start_sec); 1.170 -} 1.171 - 1.172 -void 1.173 -GCOverheadReporter::recordSTWEnd(double end_sec) { 1.174 - if (_reporter != NULL) 1.175 - _reporter->record_stw_end(end_sec); 1.176 -} 1.177 - 1.178 -void 1.179 -GCOverheadReporter::printGCOverhead() { 1.180 - if (_reporter != NULL) 1.181 - _reporter->print(); 1.182 -}