< prev index next >
src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
Print this page
*** 26,36 ****
--- 26,38 ----
#include "precompiled.hpp"
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
#include "gc_implementation/g1/g1GCPhaseTimes.hpp"
#include "gc_implementation/g1/g1Log.hpp"
#include "gc_implementation/g1/g1StringDedup.hpp"
+ #include "memory/allocation.hpp"
#include "runtime/atomic.inline.hpp"
+ #include "runtime/os.hpp"
// Helper class for avoiding interleaved logging
class LineBuffer: public StackObj {
private:
*** 79,256 ****
gclog_or_tty->print_cr("%s", _buffer);
_cur = _indent_level * INDENT_CHARS;
}
};
- PRAGMA_DIAG_PUSH
- PRAGMA_FORMAT_NONLITERAL_IGNORED
template <class T>
! void WorkerDataArray<T>::print(int level, const char* title) {
if (_length == 1) {
// No need for min, max, average and sum for only one worker
! LineBuffer buf(level);
! buf.append("[%s: ", title);
! buf.append(_print_format, _data[0]);
buf.append_and_print_cr("]");
return;
}
T min = _data[0];
T max = _data[0];
T sum = 0;
! LineBuffer buf(level);
! buf.append("[%s:", title);
for (uint i = 0; i < _length; ++i) {
T val = _data[i];
min = MIN2(val, min);
max = MAX2(val, max);
sum += val;
if (G1Log::finest()) {
buf.append(" ");
! buf.append(_print_format, val);
}
}
if (G1Log::finest()) {
buf.append_and_print_cr("%s", "");
}
double avg = (double)sum / (double)_length;
buf.append(" Min: ");
! buf.append(_print_format, min);
buf.append(", Avg: ");
buf.append("%.1lf", avg); // Always print average as a double
buf.append(", Max: ");
! buf.append(_print_format, max);
buf.append(", Diff: ");
! buf.append(_print_format, max - min);
if (_print_sum) {
// for things like the start and end times the sum is not
// that relevant
buf.append(", Sum: ");
! buf.append(_print_format, sum);
}
buf.append_and_print_cr("]");
}
- PRAGMA_DIAG_POP
#ifndef PRODUCT
! template <> const int WorkerDataArray<int>::_uninitialized = -1;
! template <> const double WorkerDataArray<double>::_uninitialized = -1.0;
! template <> const size_t WorkerDataArray<size_t>::_uninitialized = (size_t)-1;
template <class T>
void WorkerDataArray<T>::reset() {
for (uint i = 0; i < _length; i++) {
! _data[i] = (T)_uninitialized;
}
}
template <class T>
void WorkerDataArray<T>::verify() {
for (uint i = 0; i < _length; i++) {
! assert(_data[i] != _uninitialized,
! err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
! i, (double)_data[i], (double)_uninitialized));
}
}
#endif
G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
! _max_gc_threads(max_gc_threads),
! _last_gc_worker_start_times_ms(_max_gc_threads, "%.1lf", false),
! _last_ext_root_scan_times_ms(_max_gc_threads, "%.1lf"),
! _last_satb_filtering_times_ms(_max_gc_threads, "%.1lf"),
! _last_update_rs_times_ms(_max_gc_threads, "%.1lf"),
! _last_update_rs_processed_buffers(_max_gc_threads, "%d"),
! _last_scan_rs_times_ms(_max_gc_threads, "%.1lf"),
! _last_strong_code_root_scan_times_ms(_max_gc_threads, "%.1lf"),
! _last_obj_copy_times_ms(_max_gc_threads, "%.1lf"),
! _last_termination_times_ms(_max_gc_threads, "%.1lf"),
! _last_termination_attempts(_max_gc_threads, SIZE_FORMAT),
! _last_gc_worker_end_times_ms(_max_gc_threads, "%.1lf", false),
! _last_gc_worker_times_ms(_max_gc_threads, "%.1lf"),
! _last_gc_worker_other_times_ms(_max_gc_threads, "%.1lf"),
! _last_redirty_logged_cards_time_ms(_max_gc_threads, "%.1lf"),
! _last_redirty_logged_cards_processed_cards(_max_gc_threads, SIZE_FORMAT),
! _cur_string_dedup_queue_fixup_worker_times_ms(_max_gc_threads, "%.1lf"),
! _cur_string_dedup_table_fixup_worker_times_ms(_max_gc_threads, "%.1lf")
{
assert(max_gc_threads > 0, "Must have some GC threads");
}
! void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
assert(active_gc_threads > 0, "The number of threads must be > 0");
! assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max nubmer of threads");
_active_gc_threads = active_gc_threads;
! _last_gc_worker_start_times_ms.reset();
! _last_ext_root_scan_times_ms.reset();
! _last_satb_filtering_times_ms.reset();
! _last_update_rs_times_ms.reset();
! _last_update_rs_processed_buffers.reset();
! _last_scan_rs_times_ms.reset();
! _last_strong_code_root_scan_times_ms.reset();
! _last_obj_copy_times_ms.reset();
! _last_termination_times_ms.reset();
! _last_termination_attempts.reset();
! _last_gc_worker_end_times_ms.reset();
! _last_gc_worker_times_ms.reset();
! _last_gc_worker_other_times_ms.reset();
! _last_redirty_logged_cards_time_ms.reset();
! _last_redirty_logged_cards_processed_cards.reset();
}
void G1GCPhaseTimes::note_gc_end() {
- _last_gc_worker_start_times_ms.verify();
- _last_ext_root_scan_times_ms.verify();
- _last_satb_filtering_times_ms.verify();
- _last_update_rs_times_ms.verify();
- _last_update_rs_processed_buffers.verify();
- _last_scan_rs_times_ms.verify();
- _last_strong_code_root_scan_times_ms.verify();
- _last_obj_copy_times_ms.verify();
- _last_termination_times_ms.verify();
- _last_termination_attempts.verify();
- _last_gc_worker_end_times_ms.verify();
-
for (uint i = 0; i < _active_gc_threads; i++) {
! double worker_time = _last_gc_worker_end_times_ms.get(i) - _last_gc_worker_start_times_ms.get(i);
! _last_gc_worker_times_ms.set(i, worker_time);
! double worker_known_time = _last_ext_root_scan_times_ms.get(i) +
! _last_satb_filtering_times_ms.get(i) +
! _last_update_rs_times_ms.get(i) +
! _last_scan_rs_times_ms.get(i) +
! _last_strong_code_root_scan_times_ms.get(i) +
! _last_obj_copy_times_ms.get(i) +
! _last_termination_times_ms.get(i);
! double worker_other_time = worker_time - worker_known_time;
! _last_gc_worker_other_times_ms.set(i, worker_other_time);
}
! _last_gc_worker_times_ms.verify();
! _last_gc_worker_other_times_ms.verify();
!
! _last_redirty_logged_cards_time_ms.verify();
! _last_redirty_logged_cards_processed_cards.verify();
! }
!
! void G1GCPhaseTimes::note_string_dedup_fixup_start() {
! _cur_string_dedup_queue_fixup_worker_times_ms.reset();
! _cur_string_dedup_table_fixup_worker_times_ms.reset();
! }
!
! void G1GCPhaseTimes::note_string_dedup_fixup_end() {
! _cur_string_dedup_queue_fixup_worker_times_ms.verify();
! _cur_string_dedup_table_fixup_worker_times_ms.verify();
}
void G1GCPhaseTimes::print_stats(int level, const char* str, double value) {
LineBuffer(level).append_and_print_cr("[%s: %.1lf ms]", str, value);
}
--- 81,276 ----
gclog_or_tty->print_cr("%s", _buffer);
_cur = _indent_level * INDENT_CHARS;
}
};
template <class T>
! WorkerDataArray<T>::WorkerDataArray(uint length, const char* title, bool print_sum, int log_level, uint indent_level) :
! _title(title), _length(0), _print_sum(print_sum), _log_level(log_level), _indent_level(indent_level),
! _has_new_data(true), _sub_count(NULL), _enabled(true) {
! assert(length > 0, "Must have some workers to store data for");
! _length = length;
! _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
! }
!
! template <class T>
! WorkerDataArray<T>::~WorkerDataArray() {
! FREE_C_HEAP_ARRAY(T, _data);
! }
!
! template <>
! void WorkerDataArray<double>::log_value(LineBuffer& buf, double value) {
! buf.append("%.1lf", value * 1000);
! }
!
! template <>
! void WorkerDataArray<size_t>::log_value(LineBuffer& buf, size_t value) {
! buf.append(SIZE_FORMAT, value);
! }
!
! template <class T>
! void WorkerDataArray<T>::print() {
! if (_log_level > G1Log::level() || !_enabled) {
! return;
! }
!
if (_length == 1) {
// No need for min, max, average and sum for only one worker
! LineBuffer buf(_indent_level);
! buf.append("[%s: ", _title);
! log_value(buf, _data[0]);
buf.append_and_print_cr("]");
return;
}
T min = _data[0];
T max = _data[0];
T sum = 0;
! LineBuffer buf(_indent_level);
! buf.append("[%s:", _title);
for (uint i = 0; i < _length; ++i) {
T val = _data[i];
min = MIN2(val, min);
max = MAX2(val, max);
sum += val;
if (G1Log::finest()) {
buf.append(" ");
! log_value(buf, val);
}
}
if (G1Log::finest()) {
buf.append_and_print_cr("%s", "");
}
double avg = (double)sum / (double)_length;
buf.append(" Min: ");
! log_value(buf, min);
buf.append(", Avg: ");
buf.append("%.1lf", avg); // Always print average as a double
buf.append(", Max: ");
! log_value(buf, max);
buf.append(", Diff: ");
! log_value(buf, max - min);
if (_print_sum) {
// for things like the start and end times the sum is not
// that relevant
buf.append(", Sum: ");
! log_value(buf, sum);
}
buf.append_and_print_cr("]");
+
+ if (_sub_count != NULL) {
+ _sub_count->print();
+ }
}
#ifndef PRODUCT
! template <>
! size_t WorkerDataArray<size_t>::uninitialized() {
! return (size_t)-1;
! }
!
! template <>
! double WorkerDataArray<double>::uninitialized() {
! return -1.0;
! }
template <class T>
void WorkerDataArray<T>::reset() {
for (uint i = 0; i < _length; i++) {
! _data[i] = WorkerDataArray<T>::uninitialized();
! }
! if (_sub_count != NULL) {
! _sub_count->reset();
}
}
template <class T>
void WorkerDataArray<T>::verify() {
for (uint i = 0; i < _length; i++) {
! assert(_data[i] != WorkerDataArray<T>::uninitialized(),
! err_msg("Invalid data for worker %u in '%s'", i, _title));
! }
! if (_sub_count != NULL) {
! _sub_count->verify();
}
}
#endif
+ template class WorkerDataArray<double>;
+ template class WorkerDataArray<size_t>;
+
G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
! _max_gc_threads(max_gc_threads)
{
assert(max_gc_threads > 0, "Must have some GC threads");
+
+ _gc_phases[GCWorkerStart] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Start (ms)", false, G1Log::LevelFiner, 2);
+ _gc_phases[ExtRootScan] = new WorkerDataArray<double>(max_gc_threads, "Ext Root Scanning (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[SATBFiltering] = new WorkerDataArray<double>(max_gc_threads, "SATB Filtering (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[UpdateRS] = new WorkerDataArray<double>(max_gc_threads, "Update RS (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[ScanRS] = new WorkerDataArray<double>(max_gc_threads, "Scan RS (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[CodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Code Root Scanning (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[ObjCopy] = new WorkerDataArray<double>(max_gc_threads, "Object Copy (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[Termination] = new WorkerDataArray<double>(max_gc_threads, "Termination (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[GCWorkerTotal] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Total (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[GCWorkerEnd] = new WorkerDataArray<double>(max_gc_threads, "GC Worker End (ms)", false, G1Log::LevelFiner, 2);
+ _gc_phases[Other] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Other (ms)", true, G1Log::LevelFiner, 2);
+
+ _update_rs_processed_buffers = new WorkerDataArray<size_t>(max_gc_threads, "Processed Buffers", true, G1Log::LevelFiner, 3);
+ _gc_phases[UpdateRS]->link_sub_count_array(_update_rs_processed_buffers);
+
+ _termination_attempts = new WorkerDataArray<size_t>(max_gc_threads, "Termination Attempts", true, G1Log::LevelFinest, 3);
+ _gc_phases[Termination]->link_sub_count_array(_termination_attempts);
+
+ _gc_phases[StringDedupQueueFixup] = new WorkerDataArray<double>(max_gc_threads, "Queue Fixup (ms)", true, G1Log::LevelFiner, 2);
+ _gc_phases[StringDedupTableFixup] = new WorkerDataArray<double>(max_gc_threads, "Table Fixup (ms)", true, G1Log::LevelFiner, 2);
+
+ _gc_phases[RedirtyCards] = new WorkerDataArray<double>(max_gc_threads, "Parallel Redirty", true, G1Log::LevelFinest, 3);
+ _redirtied_cards = new WorkerDataArray<size_t>(max_gc_threads, "Redirtied Cards", true, G1Log::LevelFinest, 3);
+ _gc_phases[RedirtyCards]->link_sub_count_array(_redirtied_cards);
}
! void G1GCPhaseTimes::note_gc_start(uint active_gc_threads, bool mark_in_progress) {
assert(active_gc_threads > 0, "The number of threads must be > 0");
! assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max number of threads");
_active_gc_threads = active_gc_threads;
! for (int i = 0; i < Sentinel; i++) {
! _gc_phases[i]->reset();
! }
! _gc_phases[SATBFiltering]->set_enabled(mark_in_progress);
+ _gc_phases[StringDedupQueueFixup]->set_enabled(G1StringDedup::is_enabled());
+ _gc_phases[StringDedupTableFixup]->set_enabled(G1StringDedup::is_enabled());
}
void G1GCPhaseTimes::note_gc_end() {
for (uint i = 0; i < _active_gc_threads; i++) {
! double worker_time = _gc_phases[GCWorkerEnd]->get(i) - _gc_phases[GCWorkerStart]->get(i);
! record_time(GCWorkerTotal, i , worker_time);
! double worker_known_time =
! _gc_phases[ExtRootScan]->get(i) +
! _gc_phases[SATBFiltering]->get(i) +
! _gc_phases[UpdateRS]->get(i) +
! _gc_phases[ScanRS]->get(i) +
! _gc_phases[CodeRoots]->get(i) +
! _gc_phases[ObjCopy]->get(i) +
! _gc_phases[Termination]->get(i);
! record_time(Other, i, worker_time - worker_known_time);
}
! for (int i = 0; i < Sentinel; i++) {
! _gc_phases[i]->verify();
! }
}
void G1GCPhaseTimes::print_stats(int level, const char* str, double value) {
LineBuffer(level).append_and_print_cr("[%s: %.1lf ms]", str, value);
}
*** 290,324 ****
void G1GCPhaseTimes::print(double pause_time_sec) {
if (_root_region_scan_wait_time_ms > 0.0) {
print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
}
print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
! _last_gc_worker_start_times_ms.print(2, "GC Worker Start (ms)");
! _last_ext_root_scan_times_ms.print(2, "Ext Root Scanning (ms)");
! if (_last_satb_filtering_times_ms.sum() > 0.0) {
! _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)");
! }
! _last_update_rs_times_ms.print(2, "Update RS (ms)");
! _last_update_rs_processed_buffers.print(3, "Processed Buffers");
! _last_scan_rs_times_ms.print(2, "Scan RS (ms)");
! _last_strong_code_root_scan_times_ms.print(2, "Code Root Scanning (ms)");
! _last_obj_copy_times_ms.print(2, "Object Copy (ms)");
! _last_termination_times_ms.print(2, "Termination (ms)");
! if (G1Log::finest()) {
! _last_termination_attempts.print(3, "Termination Attempts");
}
- _last_gc_worker_other_times_ms.print(2, "GC Worker Other (ms)");
- _last_gc_worker_times_ms.print(2, "GC Worker Total (ms)");
- _last_gc_worker_end_times_ms.print(2, "GC Worker End (ms)");
print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
if (G1StringDedup::is_enabled()) {
print_stats(1, "String Dedup Fixup", _cur_string_dedup_fixup_time_ms, _active_gc_threads);
! _cur_string_dedup_queue_fixup_worker_times_ms.print(2, "Queue Fixup (ms)");
! _cur_string_dedup_table_fixup_worker_times_ms.print(2, "Table Fixup (ms)");
}
print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
double misc_time_ms = pause_time_sec * MILLIUNITS - accounted_time_ms();
print_stats(1, "Other", misc_time_ms);
if (_cur_verify_before_time_ms > 0.0) {
--- 310,332 ----
void G1GCPhaseTimes::print(double pause_time_sec) {
if (_root_region_scan_wait_time_ms > 0.0) {
print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
}
+
print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
! for (int i = 0; i <= GCMainPhasesLast; i++) {
! _gc_phases[i]->print();
}
print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
if (G1StringDedup::is_enabled()) {
print_stats(1, "String Dedup Fixup", _cur_string_dedup_fixup_time_ms, _active_gc_threads);
! for (int i = StringDedupPhasesFirst; i <= StringDedupPhasesLast; i++) {
! _gc_phases[i]->print();
! }
}
print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
double misc_time_ms = pause_time_sec * MILLIUNITS - accounted_time_ms();
print_stats(1, "Other", misc_time_ms);
if (_cur_verify_before_time_ms > 0.0) {
*** 338,351 ****
(_recorded_young_cset_choice_time_ms +
_recorded_non_young_cset_choice_time_ms));
print_stats(2, "Ref Proc", _cur_ref_proc_time_ms);
print_stats(2, "Ref Enq", _cur_ref_enq_time_ms);
print_stats(2, "Redirty Cards", _recorded_redirty_logged_cards_time_ms);
! if (G1Log::finest()) {
! _last_redirty_logged_cards_time_ms.print(3, "Parallel Redirty");
! _last_redirty_logged_cards_processed_cards.print(3, "Redirtied Cards");
! }
if (G1EagerReclaimHumongousObjects) {
print_stats(2, "Humongous Register", _cur_fast_reclaim_humongous_register_time_ms);
if (G1Log::finest()) {
print_stats(3, "Humongous Total", _cur_fast_reclaim_humongous_total);
print_stats(3, "Humongous Candidate", _cur_fast_reclaim_humongous_candidates);
--- 346,356 ----
(_recorded_young_cset_choice_time_ms +
_recorded_non_young_cset_choice_time_ms));
print_stats(2, "Ref Proc", _cur_ref_proc_time_ms);
print_stats(2, "Ref Enq", _cur_ref_enq_time_ms);
print_stats(2, "Redirty Cards", _recorded_redirty_logged_cards_time_ms);
! _gc_phases[RedirtyCards]->print();
if (G1EagerReclaimHumongousObjects) {
print_stats(2, "Humongous Register", _cur_fast_reclaim_humongous_register_time_ms);
if (G1Log::finest()) {
print_stats(3, "Humongous Total", _cur_fast_reclaim_humongous_total);
print_stats(3, "Humongous Candidate", _cur_fast_reclaim_humongous_candidates);
*** 364,368 ****
--- 369,382 ----
}
if (_cur_verify_after_time_ms > 0.0) {
print_stats(2, "Verify After", _cur_verify_after_time_ms);
}
}
+
+ G1GCPhaseTimesTracker::G1GCPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCPhases phase, uint worker_id) :
+ _phase_times(phase_times), _phase(phase), _worker_id(worker_id) {
+ _start_time = os::elapsedTime();
+ }
+
+ G1GCPhaseTimesTracker::~G1GCPhaseTimesTracker() {
+ _phase_times->record_time(_phase, _worker_id, os::elapsedTime() - _start_time);
+ }
< prev index next >