2657 print_info(out); 2658 } 2659 2660 // We hold the CodeHeapStateAnalytics_lock all the time, from here until we leave this function. 2661 // That prevents another thread from destroying our view on the CodeHeap. 2662 // When we request individual parts of the analysis via the jcmd interface, it is possible 2663 // that in between another thread (another jcmd user or the vm running into CodeCache OOM) 2664 // updated the aggregated data. That's a tolerable tradeoff because we can't hold a lock 2665 // across user interaction. 2666 // Acquire this lock before acquiring the CodeCache_lock. 2667 // CodeHeapStateAnalytics_lock could be held by a concurrent thread for a long time, 2668 // leading to an unnecessarily long hold time of the CodeCache_lock. 2669 ts.update(); // record starting point 2670 MutexLocker mu1(CodeHeapStateAnalytics_lock, Mutex::_no_safepoint_check_flag); 2671 out->print_cr("\n__ CodeHeapStateAnalytics lock wait took %10.3f seconds _________\n", ts.seconds()); 2672 2673 // If we serve an "allFun" call, it is beneficial to hold the CodeCache_lock 2674 // for the entire duration of aggregation and printing. That makes sure 2675 // we see a consistent picture and do not run into issues caused by 2676 // the CodeHeap being altered concurrently. 2677 Monitor* global_lock = allFun ? CodeCache_lock : NULL; 2678 Monitor* function_lock = allFun ? NULL : CodeCache_lock; 2679 ts_global.update(); // record starting point 2680 MutexLocker mu2(global_lock, Mutex::_no_safepoint_check_flag); 2681 if (global_lock != NULL) { 2682 out->print_cr("\n__ CodeCache (global) lock wait took %10.3f seconds _________\n", ts_global.seconds()); 2683 ts_global.update(); // record starting point 2684 } 2685 2686 if (aggregate) { 2687 ts.update(); // record starting point 2688 MutexLocker mu3(function_lock, Mutex::_no_safepoint_check_flag); 2689 if (function_lock != NULL) { 2690 out->print_cr("\n__ CodeCache (function) lock wait took %10.3f seconds _________\n", ts.seconds()); 2691 } 2692 2693 ts.update(); // record starting point 2694 CodeCache::aggregate(out, granularity); 2695 if (function_lock != NULL) { 2696 out->print_cr("\n__ CodeCache (function) lock hold took %10.3f seconds _________\n", ts.seconds()); 2697 } 2698 } | 2657 print_info(out); 2658 } 2659 2660 // We hold the CodeHeapStateAnalytics_lock all the time, from here until we leave this function. 2661 // That prevents another thread from destroying our view on the CodeHeap. 2662 // When we request individual parts of the analysis via the jcmd interface, it is possible 2663 // that in between another thread (another jcmd user or the vm running into CodeCache OOM) 2664 // updated the aggregated data. That's a tolerable tradeoff because we can't hold a lock 2665 // across user interaction. 2666 // Acquire this lock before acquiring the CodeCache_lock. 2667 // CodeHeapStateAnalytics_lock could be held by a concurrent thread for a long time, 2668 // leading to an unnecessarily long hold time of the CodeCache_lock. 2669 ts.update(); // record starting point 2670 MutexLocker mu1(CodeHeapStateAnalytics_lock, Mutex::_no_safepoint_check_flag); 2671 out->print_cr("\n__ CodeHeapStateAnalytics lock wait took %10.3f seconds _________\n", ts.seconds()); 2672 2673 // If we serve an "allFun" call, it is beneficial to hold the CodeCache_lock 2674 // for the entire duration of aggregation and printing. That makes sure 2675 // we see a consistent picture and do not run into issues caused by 2676 // the CodeHeap being altered concurrently. 2677 Mutex* global_lock = allFun ? CodeCache_lock : NULL; 2678 Mutex* function_lock = allFun ? NULL : CodeCache_lock; 2679 ts_global.update(); // record starting point 2680 MutexLocker mu2(global_lock, Mutex::_no_safepoint_check_flag); 2681 if (global_lock != NULL) { 2682 out->print_cr("\n__ CodeCache (global) lock wait took %10.3f seconds _________\n", ts_global.seconds()); 2683 ts_global.update(); // record starting point 2684 } 2685 2686 if (aggregate) { 2687 ts.update(); // record starting point 2688 MutexLocker mu3(function_lock, Mutex::_no_safepoint_check_flag); 2689 if (function_lock != NULL) { 2690 out->print_cr("\n__ CodeCache (function) lock wait took %10.3f seconds _________\n", ts.seconds()); 2691 } 2692 2693 ts.update(); // record starting point 2694 CodeCache::aggregate(out, granularity); 2695 if (function_lock != NULL) { 2696 out->print_cr("\n__ CodeCache (function) lock hold took %10.3f seconds _________\n", ts.seconds()); 2697 } 2698 } |