< prev index next >

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

Print this page

        

*** 29,38 **** --- 29,39 ---- class LineBuffer; template <class T> class WorkerDataArray : public CHeapObj<mtGC> { + friend class G1GCPhasePrinter; T* _data; uint _length; const char* _title; bool _print_sum; int _log_level;
*** 47,69 **** // This is not done in an MT-safe way. It is intended to allow single // threaded code to call sum() and average() multiple times in any order // without having to worry about the cost. bool _has_new_data; T _sum; double _average; - void log_value(LineBuffer& buf, T value); - public: WorkerDataArray(uint length, const char* title, bool print_sum, int log_level, uint indent_level); ~WorkerDataArray(); void link_sub_count_array(WorkerDataArray<size_t>* sub_count) { _sub_count = sub_count; } void set(uint worker_i, T value) { assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length)); assert(_data[worker_i] == WorkerDataArray<T>::uninitialized(), err_msg("Overwriting data for worker %d in %s", worker_i, _title)); _data[worker_i] = value; _has_new_data = true; --- 48,72 ---- // This is not done in an MT-safe way. It is intended to allow single // threaded code to call sum() and average() multiple times in any order // without having to worry about the cost. bool _has_new_data; T _sum; + T _min; + T _max; double _average; public: WorkerDataArray(uint length, const char* title, bool print_sum, int log_level, uint indent_level); ~WorkerDataArray(); void link_sub_count_array(WorkerDataArray<size_t>* sub_count) { _sub_count = sub_count; } + WorkerDataArray<size_t>* sub_count() { return _sub_count; } + void set(uint worker_i, T value) { assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length)); assert(_data[worker_i] == WorkerDataArray<T>::uninitialized(), err_msg("Overwriting data for worker %d in %s", worker_i, _title)); _data[worker_i] = value; _has_new_data = true;
*** 72,86 **** void set_sub_count(uint worker_i, size_t value) { assert(_sub_count != NULL, "No sub count"); _sub_count->set(worker_i, value); } - size_t sub_count_sum() { - assert(_sub_count != NULL, "No sub count"); - return _sub_count->sum(); - } - T get(uint worker_i) { assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length)); assert(_data[worker_i] != WorkerDataArray<T>::uninitialized(), err_msg("No data to add to for worker %d", worker_i)); return _data[worker_i]; } --- 75,84 ----
*** 91,114 **** _data[worker_i] += value; _has_new_data = true; } double average(){ - if (_has_new_data) { calculate_totals(); - } return _average; } T sum() { - if (_has_new_data) { calculate_totals(); - } return _sum; } ! void print(); void reset() PRODUCT_RETURN; void verify() PRODUCT_RETURN; void set_enabled(bool enabled) { _enabled = enabled; } --- 89,116 ---- _data[worker_i] += value; _has_new_data = true; } double average(){ calculate_totals(); return _average; } T sum() { calculate_totals(); return _sum; } ! T minimum() { ! calculate_totals(); ! return _min; ! } ! ! T maximum() { ! calculate_totals(); ! return _max; ! } void reset() PRODUCT_RETURN; void verify() PRODUCT_RETURN; void set_enabled(bool enabled) { _enabled = enabled; }
*** 116,135 **** int log_level() { return _log_level; } private: void calculate_totals(){ _sum = (T)0; for (uint i = 0; i < _length; ++i) { ! _sum += _data[i]; } _average = (double)_sum / (double)_length; _has_new_data = false; } }; class G1GCPhaseTimes : public CHeapObj<mtGC> { uint _active_gc_threads; uint _max_gc_threads; public: enum GCPhases { --- 118,148 ---- int log_level() { return _log_level; } private: void calculate_totals(){ + if (!_has_new_data) { + return; + } + _sum = (T)0; + _min = _data[0]; + _max = _min; for (uint i = 0; i < _length; ++i) { ! T val = _data[i]; ! _sum += val; ! _min = MIN2(_min, val); ! _max = MAX2(_max, val); } _average = (double)_sum / (double)_length; _has_new_data = false; } }; class G1GCPhaseTimes : public CHeapObj<mtGC> { + friend class G1GCPhasePrinter; + uint _active_gc_threads; uint _max_gc_threads; public: enum GCPhases {
*** 204,233 **** G1GCPhaseTimes(uint max_gc_threads); void note_gc_start(uint active_gc_threads, bool mark_in_progress); void note_gc_end(); void print(double pause_time_sec); ! void record_time(GCPhases phase, uint worker_i, double time) { ! _gc_phases[phase]->set(worker_i, time); } ! void add_time(GCPhases phase, uint worker_i, double time) { ! _gc_phases[phase]->add(worker_i, time); } void record_sub_count(GCPhases phase, uint worker_i, size_t count) { _gc_phases[phase]->set_sub_count(worker_i, count); } ! double average_time(GCPhases phase) { ! return _gc_phases[phase]->average(); } size_t sub_count_sum(GCPhases phase) { ! return _gc_phases[phase]->sub_count_sum(); } void record_clear_ct_time(double ms) { _cur_clear_ct_time_ms = ms; } void record_par_time(double ms) { --- 217,295 ---- G1GCPhaseTimes(uint max_gc_threads); void note_gc_start(uint active_gc_threads, bool mark_in_progress); void note_gc_end(); void print(double pause_time_sec); ! // record the time a phase took in seconds ! void record_time_secs(GCPhases phase, uint worker_i, double secs) { ! _gc_phases[phase]->set(worker_i, secs); } ! // add a number of seconds to a phase ! void add_time_secs(GCPhases phase, uint worker_i, double secs) { ! _gc_phases[phase]->add(worker_i, secs); } void record_sub_count(GCPhases phase, uint worker_i, size_t count) { _gc_phases[phase]->set_sub_count(worker_i, count); } ! // return the average time for a phase in milliseconds ! double average_time_ms(GCPhases phase) { ! return _gc_phases[phase]->average() * 1000.0; } size_t sub_count_sum(GCPhases phase) { ! assert(_gc_phases[phase]->sub_count() != NULL, "No sub count"); ! return _gc_phases[phase]->sub_count()->sum(); ! } ! ! private: ! ! double get_time_ms(GCPhases phase, uint worker_i) { ! return _gc_phases[phase]->get(worker_i) * 1000.0; ! } ! ! double sum_time_ms(GCPhases phase) { ! return _gc_phases[phase]->sum() * 1000.0; } + double min_time_ms(GCPhases phase) { + return _gc_phases[phase]->minimum() * 1000.0; + } + + double max_time_ms(GCPhases phase) { + return _gc_phases[phase]->maximum() * 1000.0; + } + + size_t get_sub_count(GCPhases phase, uint worker_i) { + assert(_gc_phases[phase]->sub_count() != NULL, "No sub count"); + return _gc_phases[phase]->sub_count()->get(worker_i); + } + + size_t sum_sub_count(GCPhases phase) { + assert(_gc_phases[phase]->sub_count() != NULL, "No sub count"); + return _gc_phases[phase]->sub_count()->sum(); + } + + double average_sub_count(GCPhases phase) { + assert(_gc_phases[phase]->sub_count() != NULL, "No sub count"); + return _gc_phases[phase]->sub_count()->average(); + } + + size_t min_sub_count(GCPhases phase) { + assert(_gc_phases[phase]->sub_count() != NULL, "No sub count"); + return _gc_phases[phase]->sub_count()->minimum(); + } + + size_t max_sub_count(GCPhases phase) { + assert(_gc_phases[phase]->sub_count() != NULL, "No sub count"); + return _gc_phases[phase]->sub_count()->maximum(); + } + + public: + void record_clear_ct_time(double ms) { _cur_clear_ct_time_ms = ms; } void record_par_time(double ms) {
*** 360,365 **** --- 422,439 ---- public: G1GCPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCPhases phase, uint worker_id); ~G1GCPhaseTimesTracker(); }; + class G1GCPhasePrinter : public StackObj { + G1GCPhaseTimes* _phase_times; + void print_single_length(G1GCPhaseTimes::GCPhases phase_id, WorkerDataArray<double>* phase); + void print_multi_length(G1GCPhaseTimes::GCPhases phase_id, WorkerDataArray<double>* phase); + void print_sub_count(G1GCPhaseTimes::GCPhases phase_id, WorkerDataArray<size_t>* sub_count); + void print_time_values(LineBuffer& buf, G1GCPhaseTimes::GCPhases phase_id, WorkerDataArray<double>* phase); + void print_count_values(LineBuffer& buf, G1GCPhaseTimes::GCPhases phase_id, WorkerDataArray<size_t>* phase); + public: + G1GCPhasePrinter(G1GCPhaseTimes* phase_times) : _phase_times(phase_times) {} + void print(G1GCPhaseTimes::GCPhases phase_id); + }; + #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
< prev index next >