diff --git a/src/share/vm/code/codeCache.hpp b/src/share/vm/code/codeCache.hpp index 966304f..c345d71 100644 --- a/src/share/vm/code/codeCache.hpp +++ b/src/share/vm/code/codeCache.hpp @@ -159,6 +159,10 @@ class CodeCache : AllStatic { // Profiling static address first_address(); // first address used for CodeBlobs static address last_address(); // last address used for CodeBlobs + + static size_t used() { return _heap->allocated_capacity(); } static size_t capacity() { return _heap->capacity(); } static size_t max_capacity() { return _heap->max_capacity(); } static size_t unallocated_capacity() { return _heap->unallocated_capacity(); } diff --git a/src/share/vm/compiler/compileBroker.cpp b/src/share/vm/compiler/compileBroker.cpp index dad99ec..d5f27a8 100644 --- a/src/share/vm/compiler/compileBroker.cpp +++ b/src/share/vm/compiler/compileBroker.cpp @@ -154,6 +154,17 @@ PerfCounter* CompileBroker::_perf_total_standard_compile_count = NULL; PerfCounter* CompileBroker::_perf_sum_osr_bytes_compiled = NULL; PerfCounter* CompileBroker::_perf_sum_standard_bytes_compiled = NULL; + +PerfVariable* CompileBroker::_perf_code_cache_used = NULL; +PerfVariable* CompileBroker::_perf_code_cache_capacity = NULL; +PerfVariable* CompileBroker::_perf_code_cache_max_capacity = NULL; + +PerfVariable* CompileBroker::_perf_code_cache_sweeps_total_num = NULL; +PerfVariable* CompileBroker::_perf_code_cache_sweeps_total_time_millis = NULL; +PerfVariable* CompileBroker::_perf_code_cache_methods_reclaimed_total_num = NULL; + PerfCounter* CompileBroker::_perf_sum_nmethod_size = NULL; PerfCounter* CompileBroker::_perf_sum_nmethod_code_size = NULL; @@ -961,6 +972,33 @@ void CompileBroker::compilation_init() { PerfDataManager::create_counter(SUN_CI, "standardBytes", PerfData::U_Bytes, CHECK); + _perf_code_cache_used = + PerfDataManager::create_variable(SUN_CI, "codeCacheUsed", + PerfData::U_Bytes, (jlong)0, CHECK); + + _perf_code_cache_capacity = + PerfDataManager::create_variable(SUN_CI, "codeCacheCapacity", + PerfData::U_Bytes, (jlong)0, CHECK); + + _perf_code_cache_max_capacity = + PerfDataManager::create_variable(SUN_CI, "codeCacheMaxCapacity", + PerfData::U_Bytes, (jlong)0, CHECK); + + _perf_code_cache_sweeps_total_num = + PerfDataManager::create_variable(SUN_CI, "codeCacheSweepsTotalNum", + PerfData::U_Bytes, (jlong)0, CHECK); + + _perf_code_cache_sweeps_total_time_millis = + PerfDataManager::create_variable(SUN_CI, "codeCacheSweepsTotalTimeMillis", + PerfData::U_Bytes, (jlong)0, CHECK); + + _perf_code_cache_methods_reclaimed_total_num = + PerfDataManager::create_variable(SUN_CI, "codeCacheMethodsReclaimedNum", + PerfData::U_Bytes, (jlong)0, CHECK); + + _perf_sum_nmethod_size = PerfDataManager::create_counter(SUN_CI, "nmethodSize", PerfData::U_Bytes, CHECK); @@ -2340,9 +2378,30 @@ void CompileBroker::collect_statistics(CompilerThread* thread, elapsedTimer time _total_standard_compile_count++; } } - // set the current method for the thread to null - if (UsePerfData) counters->set_current_method(""); + + if (UsePerfData) { + // set the current method for the thread to null + counters->set_current_method(""); + + // Update the code cache counters + update_code_cache_stats(); + } +} + +void CompileBroker::update_code_cache_stats() { + assert(UsePerfData, "perf data isn't enabled"); + _perf_code_cache_used->set_value(CodeCache::used()); + _perf_code_cache_capacity->set_value(CodeCache::capacity()); + _perf_code_cache_max_capacity->set_value(CodeCache::max_capacity()); + + _perf_code_cache_sweeps_total_num->set_value(NMethodSweeper::total_nof_code_cache_sweeps()); + _perf_code_cache_sweeps_total_time_millis->set_value(NMethodSweeper::total_time_sweeping_millis()); + _perf_code_cache_methods_reclaimed_total_num->set_value(NMethodSweeper::total_nof_methods_reclaimed()); } const char* CompileBroker::compiler_name(int comp_level) { AbstractCompiler *comp = CompileBroker::compiler(comp_level); diff --git a/src/share/vm/compiler/compileBroker.hpp b/src/share/vm/compiler/compileBroker.hpp index 7a381cd..fa5b69a 100644 --- a/src/share/vm/compiler/compileBroker.hpp +++ b/src/share/vm/compiler/compileBroker.hpp @@ -307,6 +307,20 @@ class CompileBroker: AllStatic { static PerfCounter* _perf_sum_osr_bytes_compiled; static PerfCounter* _perf_sum_standard_bytes_compiled; + + // Code Cache Space: used, (committed) capacity & (reserved) max_capacity + static PerfVariable* _perf_code_cache_used; + static PerfVariable* _perf_code_cache_capacity; + static PerfVariable* _perf_code_cache_max_capacity; + + // NMethod Sweeper stats: number of sweeps, time spent in sweeps, methods reclaimed + static PerfVariable* _perf_code_cache_sweeps_total_num; + static PerfVariable* _perf_code_cache_sweeps_total_time_millis; + static PerfVariable* _perf_code_cache_methods_reclaimed_total_num; + + // Compiled Code Blobs: cumulative size and cumulative instructions static PerfCounter* _perf_sum_nmethod_size; static PerfCounter* _perf_sum_nmethod_code_size; @@ -473,6 +487,11 @@ class CompileBroker: AllStatic { static int get_sum_nmethod_code_size() { return _sum_nmethod_code_size; } static long get_peak_compilation_time() { return _peak_compilation_time; } static long get_total_compilation_time() { return _t_total_compilation.milliseconds(); } + + // Performance counter flushing + static void update_code_cache_stats(); // called by nmethod sweeper }; #endif // SHARE_VM_COMPILER_COMPILEBROKER_HPP diff --git a/src/share/vm/runtime/sweeper.cpp b/src/share/vm/runtime/sweeper.cpp index 4eba81d..e9a7dd7 100644 --- a/src/share/vm/runtime/sweeper.cpp +++ b/src/share/vm/runtime/sweeper.cpp @@ -429,6 +429,12 @@ void NMethodSweeper::sweep_code_cache() { CompileBroker::set_should_compile_new_jobs(CompileBroker::run_compilation); log_sweep("restart_compiler"); } + + if (UsePerfData) { + CompileBroker::update_code_cache_stats(); + } } /** diff --git a/src/share/vm/runtime/sweeper.hpp b/src/share/vm/runtime/sweeper.hpp index f7482d8..35bd200 100644 --- a/src/share/vm/runtime/sweeper.hpp +++ b/src/share/vm/runtime/sweeper.hpp @@ -90,7 +90,12 @@ class NMethodSweeper : public AllStatic { public: static long traversal_count() { return _traversals; } - static int total_nof_methods_reclaimed() { return _total_nof_methods_reclaimed; } + static long total_nof_code_cache_sweeps() { return _total_nof_code_cache_sweeps; } + static long total_nof_methods_reclaimed() { return _total_nof_methods_reclaimed; } + static long total_time_sweeping_millis() { return TicksToTimeHelper::milliseconds(_total_time_sweeping); } + static const Tickspan total_time_sweeping() { return _total_time_sweeping; } static const Tickspan peak_sweep_time() { return _peak_sweep_time; } static const Tickspan peak_sweep_fraction_time() { return _peak_sweep_fraction_time; }