duke@435: /* stefank@2314: * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP stefank@2314: stefank@2314: #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" stefank@2314: #include "gc_implementation/shared/gcAdaptivePolicyCounters.hpp" stefank@2314: #include "gc_implementation/shared/gcStats.hpp" stefank@2314: #include "runtime/perfData.hpp" stefank@2314: duke@435: // CMSGCAdaptivePolicyCounters is a holder class for performance counters duke@435: // that track the data and decisions for the ergonomics policy for the duke@435: // concurrent mark sweep collector duke@435: duke@435: class CMSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters { duke@435: friend class VMStructs; duke@435: duke@435: private: duke@435: duke@435: // Capacity of tenured generation recorded at the end of duke@435: // any collection. duke@435: PerfVariable* _cms_capacity_counter; // Make this common with PS _old_capacity duke@435: duke@435: // Average stop-the-world pause time for both initial and duke@435: // remark pauses sampled at the end of the checkpointRootsFinalWork. duke@435: PerfVariable* _avg_cms_STW_time_counter; duke@435: // Average stop-the-world (STW) GC cost for the STW pause time duke@435: // _avg_cms_STW_time_counter. duke@435: PerfVariable* _avg_cms_STW_gc_cost_counter; duke@435: duke@435: #ifdef NOT_PRODUCT duke@435: // These are useful to see how the most recent values of these duke@435: // counters compare to their respective averages but duke@435: // do not control behavior. duke@435: PerfVariable* _initial_pause_counter; duke@435: PerfVariable* _remark_pause_counter; duke@435: #endif duke@435: duke@435: // Average of the initial marking pause for a concurrent collection. duke@435: PerfVariable* _avg_initial_pause_counter; duke@435: // Average of the remark pause for a concurrent collection. duke@435: PerfVariable* _avg_remark_pause_counter; duke@435: duke@435: // Average for the sum of all the concurrent times per collection. duke@435: PerfVariable* _avg_concurrent_time_counter; duke@435: // Average for the time between the most recent end of a duke@435: // concurrent collection and the beginning of the next duke@435: // concurrent collection. duke@435: PerfVariable* _avg_concurrent_interval_counter; duke@435: // Average of the concurrent GC costs based on _avg_concurrent_time_counter duke@435: // and _avg_concurrent_interval_counter. duke@435: PerfVariable* _avg_concurrent_gc_cost_counter; duke@435: duke@435: // Average of the free space in the tenured generation at the duke@435: // end of the sweep of the tenured generation. duke@435: PerfVariable* _avg_cms_free_counter; duke@435: // Average of the free space in the tenured generation at the twisti@1040: // start of the sweep of the tenured generation. duke@435: PerfVariable* _avg_cms_free_at_sweep_counter; duke@435: // Average of the free space in the tenured generation at the duke@435: // after any resizing of the tenured generation at the end duke@435: // of a collection of the tenured generation. duke@435: PerfVariable* _avg_cms_promo_counter; duke@435: duke@435: // Average of the mark-sweep-compact (MSC) pause time for a collection duke@435: // of the tenured generation. duke@435: PerfVariable* _avg_msc_pause_counter; duke@435: // Average for the time between the most recent end of a duke@435: // MSC collection and the beginning of the next duke@435: // MSC collection. duke@435: PerfVariable* _avg_msc_interval_counter; duke@435: // Average for the GC cost of a MSC collection based on duke@435: // _avg_msc_pause_counter and _avg_msc_interval_counter. duke@435: PerfVariable* _msc_gc_cost_counter; duke@435: duke@435: // Average of the mark-sweep (MS) pause time for a collection duke@435: // of the tenured generation. duke@435: PerfVariable* _avg_ms_pause_counter; duke@435: // Average for the time between the most recent end of a duke@435: // MS collection and the beginning of the next duke@435: // MS collection. duke@435: PerfVariable* _avg_ms_interval_counter; duke@435: // Average for the GC cost of a MS collection based on duke@435: // _avg_ms_pause_counter and _avg_ms_interval_counter. duke@435: PerfVariable* _ms_gc_cost_counter; duke@435: duke@435: // Average of the bytes promoted per minor collection. duke@435: PerfVariable* _promoted_avg_counter; duke@435: // Average of the deviation of the promoted average duke@435: PerfVariable* _promoted_avg_dev_counter; duke@435: // Padded average of the bytes promoted per minor colleciton duke@435: PerfVariable* _promoted_padded_avg_counter; duke@435: duke@435: // See description of the _change_young_gen_for_maj_pauses duke@435: // variable recently in cmsAdaptiveSizePolicy.hpp. duke@435: PerfVariable* _change_young_gen_for_maj_pauses_counter; duke@435: duke@435: // See descriptions of _remark_pause_old_slope, _initial_pause_old_slope, duke@435: // etc. variables recently in cmsAdaptiveSizePolicy.hpp. duke@435: PerfVariable* _remark_pause_old_slope_counter; duke@435: PerfVariable* _initial_pause_old_slope_counter; duke@435: PerfVariable* _remark_pause_young_slope_counter; duke@435: PerfVariable* _initial_pause_young_slope_counter; duke@435: duke@435: CMSAdaptiveSizePolicy* cms_size_policy() { duke@435: assert(_size_policy->kind() == duke@435: AdaptiveSizePolicy::_gc_cms_adaptive_size_policy, duke@435: "Wrong size policy"); duke@435: return (CMSAdaptiveSizePolicy*)_size_policy; duke@435: } duke@435: duke@435: inline void update_avg_cms_STW_time_counter() { duke@435: _avg_cms_STW_time_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_cms_STW_time()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_avg_cms_STW_gc_cost_counter() { duke@435: _avg_cms_STW_gc_cost_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_cms_STW_gc_cost()->average() * 100.0)); duke@435: } duke@435: duke@435: inline void update_avg_initial_pause_counter() { duke@435: _avg_initial_pause_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_initial_pause()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: #ifdef NOT_PRODUCT duke@435: inline void update_avg_remark_pause_counter() { duke@435: _avg_remark_pause_counter->set_value( duke@435: (jlong) (cms_size_policy()-> avg_remark_pause()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_initial_pause_counter() { duke@435: _initial_pause_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_initial_pause()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: #endif duke@435: inline void update_remark_pause_counter() { duke@435: _remark_pause_counter->set_value( duke@435: (jlong) (cms_size_policy()-> avg_remark_pause()->last_sample() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_avg_concurrent_time_counter() { duke@435: _avg_concurrent_time_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_concurrent_time()->last_sample() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_avg_concurrent_interval_counter() { duke@435: _avg_concurrent_interval_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_concurrent_interval()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_avg_concurrent_gc_cost_counter() { duke@435: _avg_concurrent_gc_cost_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_concurrent_gc_cost()->average() * 100.0)); duke@435: } duke@435: duke@435: inline void update_avg_cms_free_counter() { duke@435: _avg_cms_free_counter->set_value( duke@435: (jlong) cms_size_policy()->avg_cms_free()->average()); duke@435: } duke@435: duke@435: inline void update_avg_cms_free_at_sweep_counter() { duke@435: _avg_cms_free_at_sweep_counter->set_value( duke@435: (jlong) cms_size_policy()->avg_cms_free_at_sweep()->average()); duke@435: } duke@435: duke@435: inline void update_avg_cms_promo_counter() { duke@435: _avg_cms_promo_counter->set_value( duke@435: (jlong) cms_size_policy()->avg_cms_promo()->average()); duke@435: } duke@435: duke@435: inline void update_avg_old_live_counter() { duke@435: _avg_old_live_counter->set_value( duke@435: (jlong)(cms_size_policy()->avg_old_live()->average()) duke@435: ); duke@435: } duke@435: duke@435: inline void update_avg_msc_pause_counter() { duke@435: _avg_msc_pause_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_msc_pause()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_avg_msc_interval_counter() { duke@435: _avg_msc_interval_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_msc_interval()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_msc_gc_cost_counter() { duke@435: _msc_gc_cost_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_msc_gc_cost()->average() * 100.0)); duke@435: } duke@435: duke@435: inline void update_avg_ms_pause_counter() { duke@435: _avg_ms_pause_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_ms_pause()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_avg_ms_interval_counter() { duke@435: _avg_ms_interval_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_ms_interval()->average() * duke@435: (double) MILLIUNITS)); duke@435: } duke@435: duke@435: inline void update_ms_gc_cost_counter() { duke@435: _ms_gc_cost_counter->set_value( duke@435: (jlong) (cms_size_policy()->avg_ms_gc_cost()->average() * 100.0)); duke@435: } duke@435: duke@435: inline void update_major_gc_cost_counter() { duke@435: _major_gc_cost_counter->set_value( duke@435: (jlong)(cms_size_policy()->cms_gc_cost() * 100.0) duke@435: ); duke@435: } duke@435: inline void update_mutator_cost_counter() { duke@435: _mutator_cost_counter->set_value( duke@435: (jlong)(cms_size_policy()->mutator_cost() * 100.0) duke@435: ); duke@435: } duke@435: duke@435: inline void update_avg_promoted_avg(CMSGCStats* gc_stats) { duke@435: _promoted_avg_counter->set_value( duke@435: (jlong)(gc_stats->avg_promoted()->average()) duke@435: ); duke@435: } duke@435: inline void update_avg_promoted_dev(CMSGCStats* gc_stats) { duke@435: _promoted_avg_dev_counter->set_value( duke@435: (jlong)(gc_stats->avg_promoted()->deviation()) duke@435: ); duke@435: } duke@435: inline void update_avg_promoted_padded_avg(CMSGCStats* gc_stats) { duke@435: _promoted_padded_avg_counter->set_value( duke@435: (jlong)(gc_stats->avg_promoted()->padded_average()) duke@435: ); duke@435: } duke@435: inline void update_remark_pause_old_slope_counter() { duke@435: _remark_pause_old_slope_counter->set_value( duke@435: (jlong)(cms_size_policy()->remark_pause_old_slope() * 1000) duke@435: ); duke@435: } duke@435: inline void update_initial_pause_old_slope_counter() { duke@435: _initial_pause_old_slope_counter->set_value( duke@435: (jlong)(cms_size_policy()->initial_pause_old_slope() * 1000) duke@435: ); duke@435: } duke@435: inline void update_remark_pause_young_slope_counter() { duke@435: _remark_pause_young_slope_counter->set_value( duke@435: (jlong)(cms_size_policy()->remark_pause_young_slope() * 1000) duke@435: ); duke@435: } duke@435: inline void update_initial_pause_young_slope_counter() { duke@435: _initial_pause_young_slope_counter->set_value( duke@435: (jlong)(cms_size_policy()->initial_pause_young_slope() * 1000) duke@435: ); duke@435: } duke@435: inline void update_change_young_gen_for_maj_pauses() { duke@435: _change_young_gen_for_maj_pauses_counter->set_value( duke@435: cms_size_policy()->change_young_gen_for_maj_pauses()); duke@435: } duke@435: duke@435: public: duke@435: CMSGCAdaptivePolicyCounters(const char* name, int collectors, int generations, duke@435: AdaptiveSizePolicy* size_policy); duke@435: duke@435: // update counters duke@435: void update_counters(); duke@435: void update_counters(CMSGCStats* gc_stats); duke@435: void update_counters_from_policy(); duke@435: duke@435: inline void update_cms_capacity_counter(size_t size_in_bytes) { duke@435: _cms_capacity_counter->set_value(size_in_bytes); duke@435: } duke@435: duke@435: virtual GCPolicyCounters::Name kind() const { duke@435: return GCPolicyCounters::CMSGCAdaptivePolicyCountersKind; duke@435: } duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP