1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Fri Jul 16 10:09:15 2010 -0700 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Fri Jul 16 21:33:21 2010 -0700 1.3 @@ -90,10 +90,7 @@ 1.4 } 1.5 1.6 void PSPromotionManager::post_scavenge() { 1.7 -#if PS_PM_STATS 1.8 - print_stats(); 1.9 -#endif // PS_PM_STATS 1.10 - 1.11 + TASKQUEUE_STATS_ONLY(if (PrintGCDetails && ParallelGCVerbose) print_stats()); 1.12 for (uint i = 0; i < ParallelGCThreads + 1; i++) { 1.13 PSPromotionManager* manager = manager_array(i); 1.14 if (UseDepthFirstScavengeOrder) { 1.15 @@ -105,37 +102,58 @@ 1.16 } 1.17 } 1.18 1.19 -#if PS_PM_STATS 1.20 - 1.21 +#if TASKQUEUE_STATS 1.22 void 1.23 -PSPromotionManager::print_stats(uint i) { 1.24 - tty->print_cr("---- GC Worker %2d Stats", i); 1.25 - tty->print_cr(" total pushes %8d", _total_pushes); 1.26 - tty->print_cr(" masked pushes %8d", _masked_pushes); 1.27 - tty->print_cr(" overflow pushes %8d", _overflow_pushes); 1.28 - tty->print_cr(" max overflow length %8d", _max_overflow_length); 1.29 - tty->print_cr(""); 1.30 - tty->print_cr(" arrays chunked %8d", _arrays_chunked); 1.31 - tty->print_cr(" array chunks processed %8d", _array_chunks_processed); 1.32 - tty->print_cr(""); 1.33 - tty->print_cr(" total steals %8d", _total_steals); 1.34 - tty->print_cr(" masked steals %8d", _masked_steals); 1.35 - tty->print_cr(""); 1.36 +PSPromotionManager::print_taskqueue_stats(uint i) const { 1.37 + const TaskQueueStats& stats = depth_first() ? 1.38 + _claimed_stack_depth.stats : _claimed_stack_breadth.stats; 1.39 + tty->print("%3u ", i); 1.40 + stats.print(); 1.41 + tty->cr(); 1.42 } 1.43 1.44 void 1.45 +PSPromotionManager::print_local_stats(uint i) const { 1.46 + #define FMT " " SIZE_FORMAT_W(10) 1.47 + tty->print_cr("%3u" FMT FMT FMT FMT, i, _masked_pushes, _masked_steals, 1.48 + _arrays_chunked, _array_chunks_processed); 1.49 + #undef FMT 1.50 +} 1.51 + 1.52 +static const char* const pm_stats_hdr[] = { 1.53 + " --------masked------- arrays array", 1.54 + "thr push steal chunked chunks", 1.55 + "--- ---------- ---------- ---------- ----------" 1.56 +}; 1.57 + 1.58 +void 1.59 PSPromotionManager::print_stats() { 1.60 - tty->print_cr("== GC Tasks Stats (%s), GC %3d", 1.61 - (UseDepthFirstScavengeOrder) ? "Depth-First" : "Breadth-First", 1.62 + const bool df = UseDepthFirstScavengeOrder; 1.63 + tty->print_cr("== GC Task Stats (%s-First), GC %3d", df ? "Depth" : "Breadth", 1.64 Universe::heap()->total_collections()); 1.65 1.66 - for (uint i = 0; i < ParallelGCThreads+1; ++i) { 1.67 - PSPromotionManager* manager = manager_array(i); 1.68 - manager->print_stats(i); 1.69 + tty->print("thr "); TaskQueueStats::print_header(1); tty->cr(); 1.70 + tty->print("--- "); TaskQueueStats::print_header(2); tty->cr(); 1.71 + for (uint i = 0; i < ParallelGCThreads + 1; ++i) { 1.72 + manager_array(i)->print_taskqueue_stats(i); 1.73 + } 1.74 + 1.75 + const uint hlines = sizeof(pm_stats_hdr) / sizeof(pm_stats_hdr[0]); 1.76 + for (uint i = 0; i < hlines; ++i) tty->print_cr(pm_stats_hdr[i]); 1.77 + for (uint i = 0; i < ParallelGCThreads + 1; ++i) { 1.78 + manager_array(i)->print_local_stats(i); 1.79 } 1.80 } 1.81 1.82 -#endif // PS_PM_STATS 1.83 +void 1.84 +PSPromotionManager::reset_stats() { 1.85 + TaskQueueStats& stats = depth_first() ? 1.86 + claimed_stack_depth()->stats : claimed_stack_breadth()->stats; 1.87 + stats.reset(); 1.88 + _masked_pushes = _masked_steals = 0; 1.89 + _arrays_chunked = _array_chunks_processed = 0; 1.90 +} 1.91 +#endif // TASKQUEUE_STATS 1.92 1.93 PSPromotionManager::PSPromotionManager() { 1.94 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.95 @@ -189,16 +207,7 @@ 1.96 1.97 _prefetch_queue.clear(); 1.98 1.99 -#if PS_PM_STATS 1.100 - _total_pushes = 0; 1.101 - _masked_pushes = 0; 1.102 - _overflow_pushes = 0; 1.103 - _max_overflow_length = 0; 1.104 - _arrays_chunked = 0; 1.105 - _array_chunks_processed = 0; 1.106 - _total_steals = 0; 1.107 - _masked_steals = 0; 1.108 -#endif // PS_PM_STATS 1.109 + TASKQUEUE_STATS_ONLY(reset_stats()); 1.110 } 1.111 1.112 1.113 @@ -423,14 +432,9 @@ 1.114 new_obj->is_objArray() && 1.115 PSChunkLargeArrays) { 1.116 // we'll chunk it 1.117 -#if PS_PM_STATS 1.118 - ++_arrays_chunked; 1.119 -#endif // PS_PM_STATS 1.120 oop* const masked_o = mask_chunked_array_oop(o); 1.121 push_depth(masked_o); 1.122 -#if PS_PM_STATS 1.123 - ++_masked_pushes; 1.124 -#endif // PS_PM_STATS 1.125 + TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); 1.126 } else { 1.127 // we'll just push its contents 1.128 new_obj->push_contents(this); 1.129 @@ -494,9 +498,7 @@ 1.130 assert(old->is_objArray(), "invariant"); 1.131 assert(old->is_forwarded(), "invariant"); 1.132 1.133 -#if PS_PM_STATS 1.134 - ++_array_chunks_processed; 1.135 -#endif // PS_PM_STATS 1.136 + TASKQUEUE_STATS_ONLY(++_array_chunks_processed); 1.137 1.138 oop const obj = old->forwardee(); 1.139 1.140 @@ -508,9 +510,7 @@ 1.141 assert(start > 0, "invariant"); 1.142 arrayOop(old)->set_length(start); 1.143 push_depth(mask_chunked_array_oop(old)); 1.144 -#if PS_PM_STATS 1.145 - ++_masked_pushes; 1.146 -#endif // PS_PM_STATS 1.147 + TASKQUEUE_STATS_ONLY(++_masked_pushes); 1.148 } else { 1.149 // this is the final chunk for this array 1.150 start = 0;