8196341: Add JFR events for parallel phases of G1
0 /* 1 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_VM_GC_G1_G1GCPHASETIMES_HPP 25 #define SHARE_VM_GC_G1_G1GCPHASETIMES_HPP 26 27 #include "gc/shared/referenceProcessorPhaseTimes.hpp" 28 #include "gc/shared/weakProcessorPhaseTimes.hpp" 29 #include "logging/logLevel.hpp" 30 #include "memory/allocation.hpp" 31 #include "utilities/macros.hpp" 32 33 class LineBuffer; 34 class G1ParScanThreadState; 35 class STWGCTimer; 36 37 template <class T> class WorkerDataArray; 38 39 class G1GCPhaseTimes : public CHeapObj<mtGC> { 40 uint _max_gc_threads; 41 jlong _gc_start_counter; 42 double _gc_pause_time_ms; 43 44 public: 45 enum GCParPhases { 46 GCWorkerStart, 47 ExtRootScan, 48 ThreadRoots, 49 StringTableRoots, 50 UniverseRoots, 51 JNIRoots, 52 ObjectSynchronizerRoots, 53 ManagementRoots, 54 SystemDictionaryRoots, 55 CLDGRoots, 56 JVMTIRoots, 57 CMRefRoots, 58 WaitForStrongCLD, 59 WeakCLDRoots, 60 SATBFiltering, 61 UpdateRS, 62 ScanHCC, 63 ScanRS, 64 CodeRoots, 65 #if INCLUDE_AOT 66 AOTCodeRoots, 67 #endif 68 ObjCopy, 69 Termination, 70 Other, 71 GCWorkerTotal, 72 GCWorkerEnd, 73 StringDedupQueueFixup, 74 StringDedupTableFixup, 75 RedirtyCards, 76 YoungFreeCSet, 77 NonYoungFreeCSet, 78 GCParPhasesSentinel 79 }; 80 81 enum GCScanRSWorkItems { 82 ScanRSScannedCards, 83 ScanRSClaimedCards, 84 ScanRSSkippedCards 85 }; 86 87 enum GCUpdateRSWorkItems { 88 UpdateRSProcessedBuffers, 89 UpdateRSScannedCards, 90 UpdateRSSkippedCards 91 }; 92 93 private: 94 // Markers for grouping the phases in the GCPhases enum above 95 static const int GCMainParPhasesLast = GCWorkerEnd; 96 static const int StringDedupPhasesFirst = StringDedupQueueFixup; 97 static const int StringDedupPhasesLast = StringDedupTableFixup; 98 99 WorkerDataArray<double>* _gc_par_phases[GCParPhasesSentinel]; 100 101 WorkerDataArray<size_t>* _update_rs_processed_buffers; 102 WorkerDataArray<size_t>* _update_rs_scanned_cards; 103 WorkerDataArray<size_t>* _update_rs_skipped_cards; 104 105 WorkerDataArray<size_t>* _scan_rs_scanned_cards; 106 WorkerDataArray<size_t>* _scan_rs_claimed_cards; 107 WorkerDataArray<size_t>* _scan_rs_skipped_cards; 108 109 WorkerDataArray<size_t>* _termination_attempts; 110 111 WorkerDataArray<size_t>* _redirtied_cards; 112 113 double _cur_collection_par_time_ms; 114 double _cur_collection_code_root_fixup_time_ms; 115 double _cur_strong_code_root_purge_time_ms; 116 117 double _cur_evac_fail_recalc_used; 118 double _cur_evac_fail_remove_self_forwards; 119 120 double _cur_string_dedup_fixup_time_ms; 121 122 double _cur_prepare_tlab_time_ms; 123 double _cur_resize_tlab_time_ms; 124 125 double _cur_derived_pointer_table_update_time_ms; 126 127 double _cur_clear_ct_time_ms; 128 double _cur_expand_heap_time_ms; 129 double _cur_ref_proc_time_ms; 130 131 double _cur_collection_start_sec; 132 double _root_region_scan_wait_time_ms; 133 134 double _external_accounted_time_ms; 135 136 double _recorded_clear_claimed_marks_time_ms; 137 138 double _recorded_young_cset_choice_time_ms; 139 double _recorded_non_young_cset_choice_time_ms; 140 141 double _recorded_redirty_logged_cards_time_ms; 142 143 double _recorded_preserve_cm_referents_time_ms; 144 145 double _recorded_merge_pss_time_ms; 146 147 double _recorded_start_new_cset_time_ms; 148 149 double _recorded_total_free_cset_time_ms; 150 151 double _recorded_serial_free_cset_time_ms; 152 153 double _cur_fast_reclaim_humongous_time_ms; 154 double _cur_fast_reclaim_humongous_register_time_ms; 155 size_t _cur_fast_reclaim_humongous_total; 156 size_t _cur_fast_reclaim_humongous_candidates; 157 size_t _cur_fast_reclaim_humongous_reclaimed; 158 159 double _cur_verify_before_time_ms; 160 double _cur_verify_after_time_ms; 161 162 ReferenceProcessorPhaseTimes _ref_phase_times; 163 WeakProcessorPhaseTimes _weak_phase_times; 164 165 double worker_time(GCParPhases phase, uint worker); 166 void note_gc_end(); 167 void reset(); 168 169 template <class T> 170 void details(T* phase, const char* indent) const; 171 172 void log_phase(WorkerDataArray<double>* phase, uint indent, outputStream* out, bool print_sum) const; 173 void debug_phase(WorkerDataArray<double>* phase) const; 174 void trace_phase(WorkerDataArray<double>* phase, bool print_sum = true) const; 175 176 void info_time(const char* name, double value) const; 177 void debug_time(const char* name, double value) const; 178 // This will print logs for both 'gc+phases' and 'gc+phases+ref'. 179 void debug_time_for_reference(const char* name, double value) const; 180 void trace_time(const char* name, double value) const; 181 void trace_count(const char* name, size_t value) const; 182 183 double print_pre_evacuate_collection_set() const; 184 double print_evacuate_collection_set() const; 185 double print_post_evacuate_collection_set() const; 186 void print_other(double accounted_ms) const; 187 188 public: 189 G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads); 190 void note_gc_start(); 191 void print(); 192 193 // record the time a phase took in seconds 194 void record_time_secs(GCParPhases phase, uint worker_i, double secs); 195 196 // add a number of seconds to a phase 197 void add_time_secs(GCParPhases phase, uint worker_i, double secs); 198 199 void record_or_add_objcopy_time_secs(uint worker_i, double secs); 200 201 void record_thread_work_item(GCParPhases phase, uint worker_i, size_t count, uint index = 0); 202 203 // return the average time for a phase in milliseconds 204 double average_time_ms(GCParPhases phase); 205 206 size_t sum_thread_work_items(GCParPhases phase, uint index = 0); 207 208 public: 209 210 void record_prepare_tlab_time_ms(double ms) { 211 _cur_prepare_tlab_time_ms = ms; 212 } 213 214 void record_resize_tlab_time_ms(double ms) { 215 _cur_resize_tlab_time_ms = ms; 216 } 217 218 void record_derived_pointer_table_update_time(double ms) { 219 _cur_derived_pointer_table_update_time_ms = ms; 220 } 221 222 void record_clear_ct_time(double ms) { 223 _cur_clear_ct_time_ms = ms; 224 } 225 226 void record_expand_heap_time(double ms) { 227 _cur_expand_heap_time_ms = ms; 228 } 229 230 void record_par_time(double ms) { 231 _cur_collection_par_time_ms = ms; 232 } 233 234 void record_code_root_fixup_time(double ms) { 235 _cur_collection_code_root_fixup_time_ms = ms; 236 } 237 238 void record_strong_code_root_purge_time(double ms) { 239 _cur_strong_code_root_purge_time_ms = ms; 240 } 241 242 void record_evac_fail_recalc_used_time(double ms) { 243 _cur_evac_fail_recalc_used = ms; 244 } 245 246 void record_evac_fail_remove_self_forwards(double ms) { 247 _cur_evac_fail_remove_self_forwards = ms; 248 } 249 250 void record_string_dedup_fixup_time(double ms) { 251 _cur_string_dedup_fixup_time_ms = ms; 252 } 253 254 void record_ref_proc_time(double ms) { 255 _cur_ref_proc_time_ms = ms; 256 } 257 258 void record_root_region_scan_wait_time(double time_ms) { 259 _root_region_scan_wait_time_ms = time_ms; 260 } 261 262 void record_total_free_cset_time_ms(double time_ms) { 263 _recorded_total_free_cset_time_ms = time_ms; 264 } 265 266 void record_serial_free_cset_time_ms(double time_ms) { 267 _recorded_serial_free_cset_time_ms = time_ms; 268 } 269 270 void record_fast_reclaim_humongous_stats(double time_ms, size_t total, size_t candidates) { 271 _cur_fast_reclaim_humongous_register_time_ms = time_ms; 272 _cur_fast_reclaim_humongous_total = total; 273 _cur_fast_reclaim_humongous_candidates = candidates; 274 } 275 276 void record_fast_reclaim_humongous_time_ms(double value, size_t reclaimed) { 277 _cur_fast_reclaim_humongous_time_ms = value; 278 _cur_fast_reclaim_humongous_reclaimed = reclaimed; 279 } 280 281 void record_young_cset_choice_time_ms(double time_ms) { 282 _recorded_young_cset_choice_time_ms = time_ms; 283 } 284 285 void record_non_young_cset_choice_time_ms(double time_ms) { 286 _recorded_non_young_cset_choice_time_ms = time_ms; 287 } 288 289 void record_redirty_logged_cards_time_ms(double time_ms) { 290 _recorded_redirty_logged_cards_time_ms = time_ms; 291 } 292 293 void record_preserve_cm_referents_time_ms(double time_ms) { 294 _recorded_preserve_cm_referents_time_ms = time_ms; 295 } 296 297 void record_merge_pss_time_ms(double time_ms) { 298 _recorded_merge_pss_time_ms = time_ms; 299 } 300 301 void record_start_new_cset_time_ms(double time_ms) { 302 _recorded_start_new_cset_time_ms = time_ms; 303 } 304 305 void record_cur_collection_start_sec(double time_ms) { 306 _cur_collection_start_sec = time_ms; 307 } 308 309 void record_verify_before_time_ms(double time_ms) { 310 _cur_verify_before_time_ms = time_ms; 311 } 312 313 void record_verify_after_time_ms(double time_ms) { 314 _cur_verify_after_time_ms = time_ms; 315 } 316 317 void inc_external_accounted_time_ms(double time_ms) { 318 _external_accounted_time_ms += time_ms; 319 } 320 321 void record_clear_claimed_marks_time_ms(double recorded_clear_claimed_marks_time_ms) { 322 _recorded_clear_claimed_marks_time_ms = recorded_clear_claimed_marks_time_ms; 323 } 324 325 double cur_collection_start_sec() { 326 return _cur_collection_start_sec; 327 } 328 329 double cur_collection_par_time_ms() { 330 return _cur_collection_par_time_ms; 331 } 332 333 double cur_clear_ct_time_ms() { 334 return _cur_clear_ct_time_ms; 335 } 336 337 double cur_expand_heap_time_ms() { 338 return _cur_expand_heap_time_ms; 339 } 340 341 double root_region_scan_wait_time_ms() { 342 return _root_region_scan_wait_time_ms; 343 } 344 345 double young_cset_choice_time_ms() { 346 return _recorded_young_cset_choice_time_ms; 347 } 348 349 double total_free_cset_time_ms() { 350 return _recorded_total_free_cset_time_ms; 351 } 352 353 double non_young_cset_choice_time_ms() { 354 return _recorded_non_young_cset_choice_time_ms; 355 } 356 357 double fast_reclaim_humongous_time_ms() { 358 return _cur_fast_reclaim_humongous_time_ms; 359 } 360 361 ReferenceProcessorPhaseTimes* ref_phase_times() { return &_ref_phase_times; } 362 363 WeakProcessorPhaseTimes* weak_phase_times() { return &_weak_phase_times; } 364 }; 365 366 class G1EvacPhaseWithTrimTimeTracker : public StackObj { 367 G1ParScanThreadState* _pss; 368 Ticks _start; 369 370 Tickspan& _total_time; 371 Tickspan& _trim_time; 372 373 bool _stopped; 374 public: 375 G1EvacPhaseWithTrimTimeTracker(G1ParScanThreadState* pss, Tickspan& total_time, Tickspan& trim_time); 376 ~G1EvacPhaseWithTrimTimeTracker(); 377 378 void stop(); 379 }; 380 381 class G1GCParPhaseTimesTracker : public CHeapObj<mtGC> { 382 protected: 383 Ticks _start_time; 384 G1GCPhaseTimes::GCParPhases _phase; 385 G1GCPhaseTimes* _phase_times; 386 uint _worker_id; 387 public: 388 G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id); 389 virtual ~G1GCParPhaseTimesTracker(); 390 }; 391 392 class G1EvacPhaseTimesTracker : public G1GCParPhaseTimesTracker { 393 Tickspan _total_time; 394 Tickspan _trim_time; 395 396 G1EvacPhaseWithTrimTimeTracker _trim_tracker; 397 public: 398 G1EvacPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1ParScanThreadState* pss, G1GCPhaseTimes::GCParPhases phase, uint w 399 virtual ~G1EvacPhaseTimesTracker(); 400 }; 401 402 #endif // SHARE_VM_GC_G1_G1GCPHASETIMES_HPP --- EOF ---