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