1 2 /* 3 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHPHASETIMEINGS_HPP 26 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHPHASETIMEINGS_HPP 27 28 #include "gc/shenandoah/shenandoahNumberSeq.hpp" 29 #include "gc/shared/workerDataArray.hpp" 30 #include "memory/allocation.hpp" 31 32 class ShenandoahCollectorPolicy; 33 class ShenandoahWorkerTimings; 34 class ShenandoahTerminationTimings; 35 class outputStream; 36 37 #define SHENANDOAH_GC_PHASE_DO(f) \ 38 f(total_pause_gross, "Total Pauses (G)") \ 39 f(total_pause, "Total Pauses (N)") \ 40 f(init_mark_gross, "Pause Init Mark (G)") \ 41 f(init_mark, "Pause Init Mark (N)") \ 42 f(accumulate_stats, " Accumulate Stats") \ 43 f(make_parsable, " Make Parsable") \ 44 f(clear_liveness, " Clear Liveness") \ 45 \ 46 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 47 f(scan_roots, " Scan Roots") \ 48 f(scan_thread_roots, " S: Thread Roots") \ 49 f(scan_code_roots, " S: Code Cache Roots") \ 50 f(scan_string_table_roots, " S: String Table Roots") \ 51 f(scan_universe_roots, " S: Universe Roots") \ 52 f(scan_jni_roots, " S: JNI Roots") \ 53 f(scan_jni_weak_roots, " S: JNI Weak Roots") \ 54 f(scan_synchronizer_roots, " S: Synchronizer Roots") \ 55 f(scan_management_roots, " S: Management Roots") \ 56 f(scan_system_dictionary_roots, " S: System Dict Roots") \ 57 f(scan_cldg_roots, " S: CLDG Roots") \ 58 f(scan_jvmti_roots, " S: JVMTI Roots") \ 59 f(scan_string_dedup_table_roots, " S: Dedup Table Roots") \ 60 f(scan_string_dedup_queue_roots, " S: Dedup Queue Roots") \ 61 f(scan_finish_queues, " S: Finish Queues" ) \ 62 \ 63 f(resize_tlabs, " Resize TLABs") \ 64 \ 65 f(final_mark_gross, "Pause Final Mark (G)") \ 66 f(final_mark, "Pause Final Mark (N)") \ 67 \ 68 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 69 f(update_roots, " Update Roots") \ 70 f(update_thread_roots, " U: Thread Roots") \ 71 f(update_code_roots, " U: Code Cache Roots") \ 72 f(update_string_table_roots, " U: String Table Roots") \ 73 f(update_universe_roots, " U: Universe Roots") \ 74 f(update_jni_roots, " U: JNI Roots") \ 75 f(update_jni_weak_roots, " U: JNI Weak Roots") \ 76 f(update_synchronizer_roots, " U: Synchronizer Roots") \ 77 f(update_management_roots, " U: Management Roots") \ 78 f(update_system_dictionary_roots, " U: System Dict Roots") \ 79 f(update_cldg_roots, " U: CLDG Roots") \ 80 f(update_jvmti_roots, " U: JVMTI Roots") \ 81 f(update_string_dedup_table_roots, " U: Dedup Table Roots") \ 82 f(update_string_dedup_queue_roots, " U: Dedup Queue Roots") \ 83 f(update_finish_queues, " U: Finish Queues") \ 84 \ 85 f(finish_queues, " Finish Queues") \ 86 f(termination, " Termination") \ 87 f(weakrefs, " Weak References") \ 88 f(weakrefs_process, " Process") \ 89 f(weakrefs_termination, " Termination") \ 90 f(purge, " System Purge") \ 91 f(purge_class_unload, " Unload Classes") \ 92 f(purge_par, " Parallel Cleanup") \ 93 f(purge_cldg, " CLDG") \ 94 f(purge_string_dedup, " String Dedup") \ 95 f(complete_liveness, " Complete Liveness") \ 96 f(retire_tlabs, " Retire TLABs") \ 97 f(sync_pinned, " Sync Pinned") \ 98 f(trash_cset, " Trash CSet") \ 99 f(prepare_evac, " Prepare Evacuation") \ 100 \ 101 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 102 f(init_evac, " Initial Evacuation") \ 103 f(evac_thread_roots, " E: Thread Roots") \ 104 f(evac_code_roots, " E: Code Cache Roots") \ 105 f(evac_string_table_roots, " E: String Table Roots") \ 106 f(evac_universe_roots, " E: Universe Roots") \ 107 f(evac_jni_roots, " E: JNI Roots") \ 108 f(evac_jni_weak_roots, " E: JNI Weak Roots") \ 109 f(evac_synchronizer_roots, " E: Synchronizer Roots") \ 110 f(evac_management_roots, " E: Management Roots") \ 111 f(evac_system_dictionary_roots, " E: System Dict Roots") \ 112 f(evac_cldg_roots, " E: CLDG Roots") \ 113 f(evac_jvmti_roots, " E: JVMTI Roots") \ 114 f(evac_string_dedup_table_roots, " E: String Dedup Table Roots") \ 115 f(evac_string_dedup_queue_roots, " E: String Dedup Queue Roots") \ 116 f(evac_finish_queues, " E: Finish Queues") \ 117 \ 118 f(final_evac_gross, "Pause Final Evac (G)") \ 119 f(final_evac, "Pause Final Evac (N)") \ 120 f(final_evac_retire_gclabs, " Retire GCLABs") \ 121 \ 122 f(init_update_refs_gross, "Pause Init Update Refs (G)") \ 123 f(init_update_refs, "Pause Init Update Refs (N)") \ 124 f(init_update_refs_retire_gclabs, " Retire GCLABs") \ 125 f(init_update_refs_prepare, " Prepare") \ 126 \ 127 f(final_update_refs_gross, "Pause Final Update Refs (G)") \ 128 f(final_update_refs, "Pause Final Update Refs (N)") \ 129 f(final_update_refs_finish_work, " Finish Work") \ 130 \ 131 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 132 f(final_update_refs_roots, " Update Roots") \ 133 f(final_update_refs_thread_roots, " UR: Thread Roots") \ 134 f(final_update_refs_code_roots, " UR: Code Cache Roots") \ 135 f(final_update_refs_string_table_roots, " UR: String Table Roots") \ 136 f(final_update_refs_universe_roots, " UR: Universe Roots") \ 137 f(final_update_refs_jni_roots, " UR: JNI Roots") \ 138 f(final_update_refs_jni_weak_roots, " UR: JNI Weak Roots") \ 139 f(final_update_refs_synchronizer_roots, " UR: Synchronizer Roots") \ 140 f(final_update_refs_management_roots, " UR: Management Roots") \ 141 f(final_update_refs_system_dict_roots, " UR: System Dict Roots") \ 142 f(final_update_refs_cldg_roots, " UR: CLDG Roots") \ 143 f(final_update_refs_jvmti_roots, " UR: JVMTI Roots") \ 144 f(final_update_refs_string_dedup_table_roots, " UR: Dedup Table Roots") \ 145 f(final_update_refs_string_dedup_queue_roots, " UR: Dedup Queue Roots") \ 146 f(final_update_refs_finish_queues, " UR: Finish Queues") \ 147 \ 148 f(final_update_refs_sync_pinned, " Sync Pinned") \ 149 f(final_update_refs_trash_cset, " Trash CSet") \ 150 \ 151 f(degen_gc_gross, "Pause Degenerated GC (G)") \ 152 f(degen_gc, "Pause Degenerated GC (N)") \ 153 \ 154 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 155 f(degen_gc_update_roots, " Degen Update Roots") \ 156 f(degen_gc_update_thread_roots, " DU: Thread Roots") \ 157 f(degen_gc_update_code_roots, " DU: Code Cache Roots") \ 158 f(degen_gc_update_string_table_roots, " DU: String Table Roots") \ 159 f(degen_gc_update_universe_roots, " DU: Universe Roots") \ 160 f(degen_gc_update_jni_roots, " DU: JNI Roots") \ 161 f(degen_gc_update_jni_weak_roots, " DU: JNI Weak Roots") \ 162 f(degen_gc_update_synchronizer_roots, " DU: Synchronizer Roots") \ 163 f(degen_gc_update_management_roots, " DU: Management Roots") \ 164 f(degen_gc_update_system_dict_roots, " DU: System Dict Roots") \ 165 f(degen_gc_update_cldg_roots, " DU: CLDG Roots") \ 166 f(degen_gc_update_jvmti_roots, " DU: JVMTI Roots") \ 167 f(degen_gc_update_string_dedup_table_roots, " DU: Dedup Table Roots") \ 168 f(degen_gc_update_string_dedup_queue_roots, " DU: Dedup Queue Roots") \ 169 f(degen_gc_update_finish_queues, " DU: Finish Queues") \ 170 \ 171 f(init_traversal_gc_gross, "Pause Init Traversal (G)") \ 172 f(init_traversal_gc, "Pause Init Traversal (N)") \ 173 f(traversal_gc_prepare, " Prepare") \ 174 f(traversal_gc_accumulate_stats, " Accumulate Stats") \ 175 f(traversal_gc_make_parsable, " Make Parsable") \ 176 f(traversal_gc_resize_tlabs, " Resize TLABs") \ 177 f(traversal_gc_prepare_sync_pinned, " Sync Pinned") \ 178 \ 179 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 180 f(init_traversal_gc_work, " Work") \ 181 f(init_traversal_gc_thread_roots, " TI: Thread Roots") \ 182 f(init_traversal_gc_code_roots, " TI: Code Cache Roots") \ 183 f(init_traversal_gc_string_table_roots, " TI: String Table Roots") \ 184 f(init_traversal_gc_universe_roots, " TI: Universe Roots") \ 185 f(init_traversal_gc_jni_roots, " TI: JNI Roots") \ 186 f(init_traversal_gc_jni_weak_roots, " TI: JNI Weak Roots") \ 187 f(init_traversal_gc_synchronizer_roots, " TI: Synchronizer Roots") \ 188 f(init_traversal_gc_management_roots, " TI: Management Roots") \ 189 f(init_traversal_gc_system_dict_roots, " TI: System Dict Roots") \ 190 f(init_traversal_gc_cldg_roots, " TI: CLDG Roots") \ 191 f(init_traversal_gc_jvmti_roots, " TI: JVMTI Roots") \ 192 f(init_traversal_gc_string_dedup_table_roots, " TI: Dedup Table Roots") \ 193 f(init_traversal_gc_string_dedup_queue_roots, " TI: Dedup Queue Roots") \ 194 f(init_traversal_gc_finish_queues, " TI: Finish Queues") \ 195 \ 196 f(final_traversal_gc_gross, "Pause Final Traversal (G)") \ 197 f(final_traversal_gc, "Pause Final Traversal (N)") \ 198 \ 199 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 200 f(final_traversal_gc_work, " Work") \ 201 f(final_traversal_gc_thread_roots, " TF: Thread Roots") \ 202 f(final_traversal_gc_code_roots, " TF: Code Cache Roots") \ 203 f(final_traversal_gc_string_table_roots, " TF: String Table Roots") \ 204 f(final_traversal_gc_universe_roots, " TF: Universe Roots") \ 205 f(final_traversal_gc_jni_roots, " TF: JNI Roots") \ 206 f(final_traversal_gc_jni_weak_roots, " TF: JNI Weak Roots") \ 207 f(final_traversal_gc_synchronizer_roots, " TF: Synchronizer Roots") \ 208 f(final_traversal_gc_management_roots, " TF: Management Roots") \ 209 f(final_traversal_gc_system_dict_roots, " TF: System Dict Roots") \ 210 f(final_traversal_gc_cldg_roots, " TF: CLDG Roots") \ 211 f(final_traversal_gc_jvmti_roots, " TF: JVMTI Roots") \ 212 f(final_traversal_gc_string_dedup_table_roots, " TF: Dedup Table Roots") \ 213 f(final_traversal_gc_string_dedup_queue_roots, " TF: Dedup Queue Roots") \ 214 f(final_traversal_gc_finish_queues, " TF: Finish Queues") \ 215 f(final_traversal_gc_termination, " TF: Termination") \ 216 \ 217 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 218 f(final_traversal_update_roots, " Update Roots") \ 219 f(final_traversal_update_thread_roots, " TU: Thread Roots") \ 220 f(final_traversal_update_code_roots, " TU: Code Cache Roots") \ 221 f(final_traversal_update_string_table_roots, " TU: String Table Roots") \ 222 f(final_traversal_update_universe_roots, " TU: Universe Roots") \ 223 f(final_traversal_update_jni_roots, " TU: JNI Roots") \ 224 f(final_traversal_update_jni_weak_roots, " TU: JNI Weak Roots") \ 225 f(final_traversal_update_synchronizer_roots, " TU: Synchronizer Roots") \ 226 f(final_traversal_update_management_roots, " TU: Management Roots") \ 227 f(final_traversal_update_system_dict_roots, " TU: System Dict Roots") \ 228 f(final_traversal_update_cldg_roots, " TU: CLDG Roots") \ 229 f(final_traversal_update_jvmti_roots, " TU: JVMTI Roots") \ 230 f(final_traversal_update_string_dedup_table_roots, " TU: Dedup Table Roots") \ 231 f(final_traversal_update_string_dedup_queue_roots, " TU: Dedup Queue Roots") \ 232 f(final_traversal_update_finish_queues, " TU: Finish Queues") \ 233 \ 234 f(traversal_gc_sync_pinned, " Sync Pinned") \ 235 f(traversal_gc_cleanup, " Cleanup") \ 236 \ 237 f(full_gc_gross, "Pause Full GC (G)") \ 238 f(full_gc, "Pause Full GC (N)") \ 239 f(full_gc_heapdumps, " Heap Dumps") \ 240 f(full_gc_prepare, " Prepare") \ 241 \ 242 /* Per-thread timer block, should have "roots" counters in consistent order */ \ 243 f(full_gc_roots, " Roots") \ 244 f(full_gc_thread_roots, " F: Thread Roots") \ 245 f(full_gc_code_roots, " F: Code Cache Roots") \ 246 f(full_gc_string_table_roots, " F: String Table Roots") \ 247 f(full_gc_universe_roots, " F: Universe Roots") \ 248 f(full_gc_jni_roots, " F: JNI Roots") \ 249 f(full_gc_jni_weak_roots, " F: JNI Weak Roots") \ 250 f(full_gc_synchronizer_roots, " F: Synchronizer Roots") \ 251 f(full_gc_management_roots, " F: Management Roots") \ 252 f(full_gc_system_dictionary_roots, " F: System Dict Roots") \ 253 f(full_gc_cldg_roots, " F: CLDG Roots") \ 254 f(full_gc_jvmti_roots, " F: JVMTI Roots") \ 255 f(full_gc_string_dedup_table_roots, " F: Dedup Table Roots") \ 256 f(full_gc_string_dedup_queue_roots, " F: Dedup Queue Roots") \ 257 f(full_gc_finish_queues, " F: Finish Queues") \ 258 \ 259 f(full_gc_mark, " Mark") \ 260 f(full_gc_mark_finish_queues, " Finish Queues") \ 261 f(full_gc_mark_termination, " Termination") \ 262 f(full_gc_weakrefs, " Weak References") \ 263 f(full_gc_weakrefs_process, " Process") \ 264 f(full_gc_weakrefs_termination, " Termination") \ 265 f(full_gc_purge, " System Purge") \ 266 f(full_gc_purge_class_unload, " Unload Classes") \ 267 f(full_gc_purge_par, " Parallel Cleanup") \ 268 f(full_gc_purge_cldg, " CLDG") \ 269 f(full_gc_purge_string_dedup, " String Dedup") \ 270 f(full_gc_calculate_addresses, " Calculate Addresses") \ 271 f(full_gc_calculate_addresses_regular, " Regular Objects") \ 272 f(full_gc_calculate_addresses_humong, " Humongous Objects") \ 273 f(full_gc_adjust_pointers, " Adjust Pointers") \ 274 f(full_gc_copy_objects, " Copy Objects") \ 275 f(full_gc_copy_objects_regular, " Regular Objects") \ 276 f(full_gc_copy_objects_humong, " Humongous Objects") \ 277 f(full_gc_copy_objects_reset_complete, " Reset Complete Bitmap") \ 278 f(full_gc_copy_objects_rebuild, " Rebuild Region Sets") \ 279 f(full_gc_resize_tlabs, " Resize TLABs") \ 280 \ 281 /* Longer concurrent phases at the end */ \ 282 f(conc_reset, "Concurrent Reset") \ 283 f(conc_mark, "Concurrent Marking") \ 284 f(conc_termination, " Termination") \ 285 f(conc_preclean, "Concurrent Precleaning") \ 286 f(conc_evac, "Concurrent Evacuation") \ 287 f(conc_update_refs, "Concurrent Update Refs") \ 288 f(conc_cleanup, "Concurrent Cleanup") \ 289 f(conc_traversal, "Concurrent Traversal") \ 290 f(conc_traversal_termination, " Termination") \ 291 \ 292 f(conc_uncommit, "Concurrent Uncommit") \ 293 \ 294 /* Unclassified */ \ 295 f(pause_other, "Pause Other") \ 296 f(conc_other, "Concurrent Other") \ 297 // end 298 299 #define SHENANDOAH_GC_PAR_PHASE_DO(f) \ 300 f(ThreadRoots, "Thread Roots (ms):") \ 301 f(CodeCacheRoots, "CodeCache Roots (ms):") \ 302 f(StringTableRoots, "StringTable Roots (ms):") \ 303 f(UniverseRoots, "Universe Roots (ms):") \ 304 f(JNIRoots, "JNI Handles Roots (ms):") \ 305 f(JNIWeakRoots, "JNI Weak Roots (ms):") \ 306 f(ObjectSynchronizerRoots, "ObjectSynchronizer Roots (ms):") \ 307 f(ManagementRoots, "Management Roots (ms):") \ 308 f(SystemDictionaryRoots, "SystemDictionary Roots (ms):") \ 309 f(CLDGRoots, "CLDG Roots (ms):") \ 310 f(JVMTIRoots, "JVMTI Roots (ms):") \ 311 f(StringDedupTableRoots, "String Dedup Table Roots (ms):") \ 312 f(StringDedupQueueRoots, "String Dedup Queue Roots (ms):") \ 313 f(FinishQueues, "Finish Queues (ms):") \ 314 // end 315 316 class ShenandoahPhaseTimings : public CHeapObj<mtGC> { 317 public: 318 #define GC_PHASE_DECLARE_ENUM(type, title) type, 319 320 enum Phase { 321 SHENANDOAH_GC_PHASE_DO(GC_PHASE_DECLARE_ENUM) 322 _num_phases 323 }; 324 325 // These are the subphases of GC phases (scan_roots, update_roots, 326 // init_evac, final_update_refs_roots and full_gc_roots). 327 // Make sure they are following this order. 328 enum GCParPhases { 329 SHENANDOAH_GC_PAR_PHASE_DO(GC_PHASE_DECLARE_ENUM) 330 GCParPhasesSentinel 331 }; 332 333 #undef GC_PHASE_DECLARE_ENUM 334 335 private: 336 struct TimingData { 337 HdrSeq _secs; 338 double _start; 339 }; 340 341 private: 342 TimingData _timing_data[_num_phases]; 343 static const char* _phase_names[_num_phases]; 344 345 ShenandoahWorkerTimings* _worker_times; 346 ShenandoahTerminationTimings* _termination_times; 347 348 ShenandoahCollectorPolicy* _policy; 349 350 public: 351 ShenandoahPhaseTimings(); 352 353 ShenandoahWorkerTimings* const worker_times() const { return _worker_times; } 354 ShenandoahTerminationTimings* const termination_times() const { return _termination_times; } 355 356 // record phase start 357 void record_phase_start(Phase phase); 358 // record phase end and return elapsed time in seconds for the phase 359 void record_phase_end(Phase phase); 360 // record an elapsed time for the phase 361 void record_phase_time(Phase phase, double time); 362 363 void record_workers_start(Phase phase); 364 void record_workers_end(Phase phase); 365 366 static const char* phase_name(Phase phase) { 367 assert(phase >= 0 && phase < _num_phases, "Out of bound"); 368 return _phase_names[phase]; 369 } 370 371 void print_on(outputStream* out) const; 372 373 private: 374 void init_phase_names(); 375 void print_summary_sd(outputStream* out, const char* str, const HdrSeq* seq) const; 376 }; 377 378 class ShenandoahWorkerTimings : public CHeapObj<mtGC> { 379 private: 380 uint _max_gc_threads; 381 WorkerDataArray<double>* _gc_par_phases[ShenandoahPhaseTimings::GCParPhasesSentinel]; 382 383 public: 384 ShenandoahWorkerTimings(uint max_gc_threads); 385 386 // record the time a phase took in seconds 387 void record_time_secs(ShenandoahPhaseTimings::GCParPhases phase, uint worker_i, double secs); 388 389 double average(uint i) const; 390 void reset(uint i); 391 void print() const; 392 }; 393 394 class ShenandoahTerminationTimings : public CHeapObj<mtGC> { 395 private: 396 WorkerDataArray<double>* _gc_termination_phase; 397 public: 398 ShenandoahTerminationTimings(uint max_gc_threads); 399 400 // record the time a phase took in seconds 401 void record_time_secs(uint worker_i, double secs); 402 403 double average() const; 404 void reset(); 405 406 void print() const; 407 }; 408 409 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHGCPHASETIMEINGS_HPP