annotate src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp @ 5971:eff02b5bd56c

8035654: Add times for evacuation failure handling in "Other" time Summary: Detailed breakdown of time spent in the evacuation failure handling phases to make the "Other" time roughly correspond to the sum of its parts. Reviewed-by: jwilhelm, jmasa
author tschatzl
date Mon, 24 Mar 2014 15:30:46 +0100
parents a07bea31ef35
children 595c0f60d50d
rev   line source
brutisso@3488 1 /*
tschatzl@5967 2 * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
brutisso@3488 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
brutisso@3488 4 *
brutisso@3488 5 * This code is free software; you can redistribute it and/or modify it
brutisso@3488 6 * under the terms of the GNU General Public License version 2 only, as
brutisso@3488 7 * published by the Free Software Foundation.
brutisso@3488 8 *
brutisso@3488 9 * This code is distributed in the hope that it will be useful, but WITHOUT
brutisso@3488 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
brutisso@3488 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
brutisso@3488 12 * version 2 for more details (a copy is included in the LICENSE file that
brutisso@3488 13 * accompanied this code).
brutisso@3488 14 *
brutisso@3488 15 * You should have received a copy of the GNU General Public License version
brutisso@3488 16 * 2 along with this work; if not, write to the Free Software Foundation,
brutisso@3488 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
brutisso@3488 18 *
brutisso@3488 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
brutisso@3488 20 * or visit www.oracle.com if you need additional information or have any
brutisso@3488 21 * questions.
brutisso@3488 22 *
brutisso@3488 23 */
brutisso@3488 24
brutisso@3488 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
brutisso@3488 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
brutisso@3488 27
brutisso@3488 28 #include "memory/allocation.hpp"
brutisso@3488 29 #include "gc_interface/gcCause.hpp"
brutisso@3488 30
brutisso@3580 31 template <class T>
brutisso@3580 32 class WorkerDataArray : public CHeapObj<mtGC> {
brutisso@3580 33 T* _data;
brutisso@3580 34 uint _length;
brutisso@3580 35 const char* _print_format;
brutisso@3580 36 bool _print_sum;
brutisso@3580 37
brutisso@4040 38 NOT_PRODUCT(static const T _uninitialized;)
brutisso@4040 39
brutisso@3580 40 // We are caching the sum and average to only have to calculate them once.
sla@4802 41 // This is not done in an MT-safe way. It is intended to allow single
brutisso@3580 42 // threaded code to call sum() and average() multiple times in any order
brutisso@3580 43 // without having to worry about the cost.
brutisso@3580 44 bool _has_new_data;
brutisso@3580 45 T _sum;
brutisso@3580 46 double _average;
brutisso@3580 47
brutisso@3580 48 public:
brutisso@3580 49 WorkerDataArray(uint length, const char* print_format, bool print_sum = true) :
brutisso@3580 50 _length(length), _print_format(print_format), _print_sum(print_sum), _has_new_data(true) {
brutisso@3580 51 assert(length > 0, "Must have some workers to store data for");
brutisso@3580 52 _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
brutisso@3580 53 }
brutisso@3580 54
brutisso@3580 55 ~WorkerDataArray() {
brutisso@3580 56 FREE_C_HEAP_ARRAY(T, _data, mtGC);
brutisso@3580 57 }
brutisso@3580 58
brutisso@3580 59 void set(uint worker_i, T value) {
brutisso@3580 60 assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
brutisso@3580 61 assert(_data[worker_i] == (T)-1, err_msg("Overwriting data for worker %d", worker_i));
brutisso@3580 62 _data[worker_i] = value;
brutisso@3580 63 _has_new_data = true;
brutisso@3580 64 }
brutisso@3580 65
brutisso@3580 66 T get(uint worker_i) {
brutisso@3580 67 assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
brutisso@3580 68 assert(_data[worker_i] != (T)-1, err_msg("No data to add to for worker %d", worker_i));
brutisso@3580 69 return _data[worker_i];
brutisso@3580 70 }
brutisso@3580 71
brutisso@3580 72 void add(uint worker_i, T value) {
brutisso@3580 73 assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
brutisso@3580 74 assert(_data[worker_i] != (T)-1, err_msg("No data to add to for worker %d", worker_i));
brutisso@3580 75 _data[worker_i] += value;
brutisso@3580 76 _has_new_data = true;
brutisso@3580 77 }
brutisso@3580 78
brutisso@3580 79 double average(){
brutisso@3580 80 if (_has_new_data) {
brutisso@3580 81 calculate_totals();
brutisso@3580 82 }
brutisso@3580 83 return _average;
brutisso@3580 84 }
brutisso@3580 85
brutisso@3580 86 T sum() {
brutisso@3580 87 if (_has_new_data) {
brutisso@3580 88 calculate_totals();
brutisso@3580 89 }
brutisso@3580 90 return _sum;
brutisso@3580 91 }
brutisso@3580 92
brutisso@3580 93 void print(int level, const char* title);
brutisso@3580 94
brutisso@3580 95 void reset() PRODUCT_RETURN;
brutisso@3580 96 void verify() PRODUCT_RETURN;
brutisso@3580 97
brutisso@3580 98 private:
brutisso@3580 99
brutisso@3580 100 void calculate_totals(){
brutisso@3580 101 _sum = (T)0;
brutisso@3580 102 for (uint i = 0; i < _length; ++i) {
brutisso@3580 103 _sum += _data[i];
brutisso@3580 104 }
brutisso@3580 105 _average = (double)_sum / (double)_length;
brutisso@3580 106 _has_new_data = false;
brutisso@3580 107 }
brutisso@3580 108 };
brutisso@3580 109
jmasa@3489 110 class G1GCPhaseTimes : public CHeapObj<mtGC> {
brutisso@3488 111
brutisso@3488 112 private:
brutisso@3488 113 uint _active_gc_threads;
brutisso@3488 114 uint _max_gc_threads;
brutisso@3488 115
brutisso@3580 116 WorkerDataArray<double> _last_gc_worker_start_times_ms;
brutisso@3580 117 WorkerDataArray<double> _last_ext_root_scan_times_ms;
brutisso@3580 118 WorkerDataArray<double> _last_satb_filtering_times_ms;
brutisso@3580 119 WorkerDataArray<double> _last_update_rs_times_ms;
brutisso@3580 120 WorkerDataArray<int> _last_update_rs_processed_buffers;
brutisso@3580 121 WorkerDataArray<double> _last_scan_rs_times_ms;
johnc@5113 122 WorkerDataArray<double> _last_strong_code_root_scan_times_ms;
johnc@5113 123 WorkerDataArray<double> _last_strong_code_root_mark_times_ms;
brutisso@3580 124 WorkerDataArray<double> _last_obj_copy_times_ms;
brutisso@3580 125 WorkerDataArray<double> _last_termination_times_ms;
brutisso@3580 126 WorkerDataArray<size_t> _last_termination_attempts;
brutisso@3580 127 WorkerDataArray<double> _last_gc_worker_end_times_ms;
brutisso@3580 128 WorkerDataArray<double> _last_gc_worker_times_ms;
brutisso@3580 129 WorkerDataArray<double> _last_gc_worker_other_times_ms;
brutisso@3488 130
brutisso@3488 131 double _cur_collection_par_time_ms;
brutisso@3488 132 double _cur_collection_code_root_fixup_time_ms;
johnc@5113 133 double _cur_strong_code_root_migration_time_ms;
tschatzl@5967 134 double _cur_strong_code_root_purge_time_ms;
brutisso@3488 135
tschatzl@5971 136 double _cur_evac_fail_recalc_used;
tschatzl@5971 137 double _cur_evac_fail_restore_remsets;
tschatzl@5971 138 double _cur_evac_fail_remove_self_forwards;
tschatzl@5971 139
brutisso@3488 140 double _cur_clear_ct_time_ms;
brutisso@3488 141 double _cur_ref_proc_time_ms;
brutisso@3488 142 double _cur_ref_enq_time_ms;
brutisso@3488 143
brutisso@3488 144 double _cur_collection_start_sec;
brutisso@3488 145 double _root_region_scan_wait_time_ms;
brutisso@3488 146
brutisso@3488 147 double _recorded_young_cset_choice_time_ms;
brutisso@3488 148 double _recorded_non_young_cset_choice_time_ms;
brutisso@3488 149
tschatzl@5970 150 double _recorded_redirty_logged_cards_time_ms;
tschatzl@5970 151
brutisso@3488 152 double _recorded_young_free_cset_time_ms;
brutisso@3488 153 double _recorded_non_young_free_cset_time_ms;
brutisso@3488 154
brutisso@3580 155 double _cur_verify_before_time_ms;
brutisso@3580 156 double _cur_verify_after_time_ms;
brutisso@3580 157
brutisso@3580 158 // Helper methods for detailed logging
brutisso@3580 159 void print_stats(int level, const char* str, double value);
brutisso@3580 160 void print_stats(int level, const char* str, double value, int workers);
brutisso@3488 161
brutisso@3488 162 public:
brutisso@3488 163 G1GCPhaseTimes(uint max_gc_threads);
brutisso@3580 164 void note_gc_start(uint active_gc_threads);
brutisso@3580 165 void note_gc_end();
brutisso@3580 166 void print(double pause_time_sec);
brutisso@3488 167
brutisso@3488 168 void record_gc_worker_start_time(uint worker_i, double ms) {
brutisso@3580 169 _last_gc_worker_start_times_ms.set(worker_i, ms);
brutisso@3488 170 }
brutisso@3488 171
brutisso@3488 172 void record_ext_root_scan_time(uint worker_i, double ms) {
brutisso@3580 173 _last_ext_root_scan_times_ms.set(worker_i, ms);
brutisso@3488 174 }
brutisso@3488 175
brutisso@3488 176 void record_satb_filtering_time(uint worker_i, double ms) {
brutisso@3580 177 _last_satb_filtering_times_ms.set(worker_i, ms);
brutisso@3488 178 }
brutisso@3488 179
brutisso@3488 180 void record_update_rs_time(uint worker_i, double ms) {
brutisso@3580 181 _last_update_rs_times_ms.set(worker_i, ms);
brutisso@3488 182 }
brutisso@3488 183
brutisso@3580 184 void record_update_rs_processed_buffers(uint worker_i, int processed_buffers) {
brutisso@3580 185 _last_update_rs_processed_buffers.set(worker_i, processed_buffers);
brutisso@3488 186 }
brutisso@3488 187
brutisso@3488 188 void record_scan_rs_time(uint worker_i, double ms) {
brutisso@3580 189 _last_scan_rs_times_ms.set(worker_i, ms);
brutisso@3488 190 }
brutisso@3488 191
johnc@5113 192 void record_strong_code_root_scan_time(uint worker_i, double ms) {
johnc@5113 193 _last_strong_code_root_scan_times_ms.set(worker_i, ms);
johnc@5113 194 }
johnc@5113 195
johnc@5113 196 void record_strong_code_root_mark_time(uint worker_i, double ms) {
johnc@5113 197 _last_strong_code_root_mark_times_ms.set(worker_i, ms);
johnc@5113 198 }
johnc@5113 199
brutisso@3488 200 void record_obj_copy_time(uint worker_i, double ms) {
brutisso@3580 201 _last_obj_copy_times_ms.set(worker_i, ms);
brutisso@3580 202 }
brutisso@3580 203
brutisso@3580 204 void add_obj_copy_time(uint worker_i, double ms) {
brutisso@3580 205 _last_obj_copy_times_ms.add(worker_i, ms);
brutisso@3488 206 }
brutisso@3488 207
brutisso@3488 208 void record_termination(uint worker_i, double ms, size_t attempts) {
brutisso@3580 209 _last_termination_times_ms.set(worker_i, ms);
brutisso@3580 210 _last_termination_attempts.set(worker_i, attempts);
brutisso@3488 211 }
brutisso@3488 212
brutisso@3488 213 void record_gc_worker_end_time(uint worker_i, double ms) {
brutisso@3580 214 _last_gc_worker_end_times_ms.set(worker_i, ms);
brutisso@3488 215 }
brutisso@3488 216
brutisso@3488 217 void record_clear_ct_time(double ms) {
brutisso@3488 218 _cur_clear_ct_time_ms = ms;
brutisso@3488 219 }
brutisso@3488 220
brutisso@3488 221 void record_par_time(double ms) {
brutisso@3488 222 _cur_collection_par_time_ms = ms;
brutisso@3488 223 }
brutisso@3488 224
brutisso@3488 225 void record_code_root_fixup_time(double ms) {
brutisso@3488 226 _cur_collection_code_root_fixup_time_ms = ms;
brutisso@3488 227 }
brutisso@3488 228
johnc@5113 229 void record_strong_code_root_migration_time(double ms) {
johnc@5113 230 _cur_strong_code_root_migration_time_ms = ms;
johnc@5113 231 }
johnc@5113 232
tschatzl@5967 233 void record_strong_code_root_purge_time(double ms) {
tschatzl@5967 234 _cur_strong_code_root_purge_time_ms = ms;
tschatzl@5967 235 }
tschatzl@5967 236
tschatzl@5971 237 void record_evac_fail_recalc_used_time(double ms) {
tschatzl@5971 238 _cur_evac_fail_recalc_used = ms;
tschatzl@5971 239 }
tschatzl@5971 240
tschatzl@5971 241 void record_evac_fail_restore_remsets(double ms) {
tschatzl@5971 242 _cur_evac_fail_restore_remsets = ms;
tschatzl@5971 243 }
tschatzl@5971 244
tschatzl@5971 245 void record_evac_fail_remove_self_forwards(double ms) {
tschatzl@5971 246 _cur_evac_fail_remove_self_forwards = ms;
tschatzl@5971 247 }
tschatzl@5971 248
brutisso@3488 249 void record_ref_proc_time(double ms) {
brutisso@3488 250 _cur_ref_proc_time_ms = ms;
brutisso@3488 251 }
brutisso@3488 252
brutisso@3488 253 void record_ref_enq_time(double ms) {
brutisso@3488 254 _cur_ref_enq_time_ms = ms;
brutisso@3488 255 }
brutisso@3488 256
brutisso@3488 257 void record_root_region_scan_wait_time(double time_ms) {
brutisso@3488 258 _root_region_scan_wait_time_ms = time_ms;
brutisso@3488 259 }
brutisso@3488 260
brutisso@3488 261 void record_young_free_cset_time_ms(double time_ms) {
brutisso@3488 262 _recorded_young_free_cset_time_ms = time_ms;
brutisso@3488 263 }
brutisso@3488 264
brutisso@3488 265 void record_non_young_free_cset_time_ms(double time_ms) {
brutisso@3488 266 _recorded_non_young_free_cset_time_ms = time_ms;
brutisso@3488 267 }
brutisso@3580 268
brutisso@3580 269 void record_young_cset_choice_time_ms(double time_ms) {
brutisso@3580 270 _recorded_young_cset_choice_time_ms = time_ms;
brutisso@3580 271 }
brutisso@3580 272
brutisso@3580 273 void record_non_young_cset_choice_time_ms(double time_ms) {
brutisso@3580 274 _recorded_non_young_cset_choice_time_ms = time_ms;
brutisso@3580 275 }
brutisso@3580 276
tschatzl@5970 277 void record_redirty_logged_cards_time_ms(double time_ms) {
tschatzl@5970 278 _recorded_redirty_logged_cards_time_ms = time_ms;
tschatzl@5970 279 }
tschatzl@5970 280
brutisso@3580 281 void record_cur_collection_start_sec(double time_ms) {
brutisso@3580 282 _cur_collection_start_sec = time_ms;
brutisso@3580 283 }
brutisso@3580 284
brutisso@3580 285 void record_verify_before_time_ms(double time_ms) {
brutisso@3580 286 _cur_verify_before_time_ms = time_ms;
brutisso@3580 287 }
brutisso@3580 288
brutisso@3580 289 void record_verify_after_time_ms(double time_ms) {
brutisso@3580 290 _cur_verify_after_time_ms = time_ms;
brutisso@3580 291 }
brutisso@3580 292
brutisso@3580 293 double accounted_time_ms();
brutisso@3580 294
brutisso@3580 295 double cur_collection_start_sec() {
brutisso@3580 296 return _cur_collection_start_sec;
brutisso@3580 297 }
brutisso@3580 298
brutisso@3580 299 double cur_collection_par_time_ms() {
brutisso@3580 300 return _cur_collection_par_time_ms;
brutisso@3580 301 }
brutisso@3580 302
brutisso@3580 303 double cur_clear_ct_time_ms() {
brutisso@3580 304 return _cur_clear_ct_time_ms;
brutisso@3580 305 }
brutisso@3580 306
brutisso@3580 307 double root_region_scan_wait_time_ms() {
brutisso@3580 308 return _root_region_scan_wait_time_ms;
brutisso@3580 309 }
brutisso@3580 310
brutisso@3580 311 double young_cset_choice_time_ms() {
brutisso@3580 312 return _recorded_young_cset_choice_time_ms;
brutisso@3580 313 }
brutisso@3580 314
brutisso@3580 315 double young_free_cset_time_ms() {
brutisso@3580 316 return _recorded_young_free_cset_time_ms;
brutisso@3580 317 }
brutisso@3580 318
brutisso@3580 319 double non_young_cset_choice_time_ms() {
brutisso@3580 320 return _recorded_non_young_cset_choice_time_ms;
brutisso@3580 321 }
brutisso@3580 322
brutisso@3580 323 double non_young_free_cset_time_ms() {
brutisso@3580 324 return _recorded_non_young_free_cset_time_ms;
brutisso@3580 325 }
brutisso@3580 326
brutisso@3580 327 double average_last_update_rs_time() {
brutisso@3580 328 return _last_update_rs_times_ms.average();
brutisso@3580 329 }
brutisso@3580 330
brutisso@3580 331 int sum_last_update_rs_processed_buffers() {
brutisso@3580 332 return _last_update_rs_processed_buffers.sum();
brutisso@3580 333 }
brutisso@3580 334
brutisso@3580 335 double average_last_scan_rs_time(){
brutisso@3580 336 return _last_scan_rs_times_ms.average();
brutisso@3580 337 }
brutisso@3580 338
johnc@5113 339 double average_last_strong_code_root_scan_time(){
johnc@5113 340 return _last_strong_code_root_scan_times_ms.average();
johnc@5113 341 }
johnc@5113 342
johnc@5113 343 double average_last_strong_code_root_mark_time(){
johnc@5113 344 return _last_strong_code_root_mark_times_ms.average();
johnc@5113 345 }
johnc@5113 346
brutisso@3580 347 double average_last_obj_copy_time() {
brutisso@3580 348 return _last_obj_copy_times_ms.average();
brutisso@3580 349 }
brutisso@3580 350
brutisso@3580 351 double average_last_termination_time() {
brutisso@3580 352 return _last_termination_times_ms.average();
brutisso@3580 353 }
brutisso@3580 354
brutisso@3580 355 double average_last_ext_root_scan_time() {
brutisso@3580 356 return _last_ext_root_scan_times_ms.average();
brutisso@3580 357 }
brutisso@3580 358
brutisso@3580 359 double average_last_satb_filtering_times_ms() {
brutisso@3580 360 return _last_satb_filtering_times_ms.average();
brutisso@3580 361 }
brutisso@3488 362 };
brutisso@3488 363
brutisso@3488 364 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP