hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp
changeset 25594 0cab903be9c5
parent 25593 ba581cb2983f
parent 25588 b7f9a6d5949e
child 25598 6d88c15e2a8f
equal deleted inserted replaced
25593:ba581cb2983f 25594:0cab903be9c5
     1 /*
       
     2  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP
       
    26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP
       
    27 
       
    28 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
       
    29 #include "gc_implementation/shared/gcAdaptivePolicyCounters.hpp"
       
    30 #include "gc_implementation/shared/gcStats.hpp"
       
    31 #include "runtime/perfData.hpp"
       
    32 
       
    33 // CMSGCAdaptivePolicyCounters is a holder class for performance counters
       
    34 // that track the data and decisions for the ergonomics policy for the
       
    35 // concurrent mark sweep collector
       
    36 
       
    37 class CMSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters {
       
    38   friend class VMStructs;
       
    39 
       
    40  private:
       
    41 
       
    42   // Capacity of tenured generation recorded at the end of
       
    43   // any collection.
       
    44   PerfVariable* _cms_capacity_counter; // Make this common with PS _old_capacity
       
    45 
       
    46   // Average stop-the-world pause time for both initial and
       
    47   // remark pauses sampled at the end of the checkpointRootsFinalWork.
       
    48   PerfVariable* _avg_cms_STW_time_counter;
       
    49   // Average stop-the-world (STW) GC cost for the STW pause time
       
    50   // _avg_cms_STW_time_counter.
       
    51   PerfVariable* _avg_cms_STW_gc_cost_counter;
       
    52 
       
    53 #ifdef NOT_PRODUCT
       
    54   // These are useful to see how the most recent values of these
       
    55   // counters compare to their respective averages but
       
    56   // do not control behavior.
       
    57   PerfVariable* _initial_pause_counter;
       
    58   PerfVariable* _remark_pause_counter;
       
    59 #endif
       
    60 
       
    61   // Average of the initial marking pause for a concurrent collection.
       
    62   PerfVariable* _avg_initial_pause_counter;
       
    63   // Average of the remark pause for a concurrent collection.
       
    64   PerfVariable* _avg_remark_pause_counter;
       
    65 
       
    66   // Average for the sum of all the concurrent times per collection.
       
    67   PerfVariable* _avg_concurrent_time_counter;
       
    68   // Average for the time between the most recent end of a
       
    69   // concurrent collection and the beginning of the next
       
    70   // concurrent collection.
       
    71   PerfVariable* _avg_concurrent_interval_counter;
       
    72   // Average of the concurrent GC costs based on _avg_concurrent_time_counter
       
    73   // and _avg_concurrent_interval_counter.
       
    74   PerfVariable* _avg_concurrent_gc_cost_counter;
       
    75 
       
    76   // Average of the free space in the tenured generation at the
       
    77   // end of the sweep of the tenured generation.
       
    78   PerfVariable* _avg_cms_free_counter;
       
    79   // Average of the free space in the tenured generation at the
       
    80   // start of the sweep of the tenured generation.
       
    81   PerfVariable* _avg_cms_free_at_sweep_counter;
       
    82   // Average of the free space in the tenured generation at the
       
    83   // after any resizing of the tenured generation at the end
       
    84   // of a collection of the tenured generation.
       
    85   PerfVariable* _avg_cms_promo_counter;
       
    86 
       
    87   // Average of  the mark-sweep-compact (MSC) pause time for a collection
       
    88   // of the tenured generation.
       
    89   PerfVariable* _avg_msc_pause_counter;
       
    90   // Average for the time between the most recent end of a
       
    91   // MSC collection and the beginning of the next MSC collection.
       
    92   PerfVariable* _avg_msc_interval_counter;
       
    93   // Average for the GC cost of a MSC collection based on
       
    94   // _avg_msc_pause_counter and _avg_msc_interval_counter.
       
    95   PerfVariable* _msc_gc_cost_counter;
       
    96 
       
    97   // Average of  the mark-sweep (MS) pause time for a collection
       
    98   // of the tenured generation.
       
    99   PerfVariable* _avg_ms_pause_counter;
       
   100   // Average for the time between the most recent end of a
       
   101   // MS collection and the beginning of the next MS collection.
       
   102   PerfVariable* _avg_ms_interval_counter;
       
   103   // Average for the GC cost of a MS collection based on
       
   104   // _avg_ms_pause_counter and _avg_ms_interval_counter.
       
   105   PerfVariable* _ms_gc_cost_counter;
       
   106 
       
   107   // Average of the bytes promoted per minor collection.
       
   108   PerfVariable* _promoted_avg_counter;
       
   109   // Average of the deviation of the promoted average.
       
   110   PerfVariable* _promoted_avg_dev_counter;
       
   111   // Padded average of the bytes promoted per minor collection.
       
   112   PerfVariable* _promoted_padded_avg_counter;
       
   113 
       
   114   // See description of the _change_young_gen_for_maj_pauses
       
   115   // variable recently in cmsAdaptiveSizePolicy.hpp.
       
   116   PerfVariable* _change_young_gen_for_maj_pauses_counter;
       
   117 
       
   118   // See descriptions of _remark_pause_old_slope, _initial_pause_old_slope,
       
   119   // etc. variables recently in cmsAdaptiveSizePolicy.hpp.
       
   120   PerfVariable* _remark_pause_old_slope_counter;
       
   121   PerfVariable* _initial_pause_old_slope_counter;
       
   122   PerfVariable* _remark_pause_young_slope_counter;
       
   123   PerfVariable* _initial_pause_young_slope_counter;
       
   124 
       
   125   CMSAdaptiveSizePolicy* cms_size_policy() {
       
   126     assert(_size_policy->kind() ==
       
   127       AdaptiveSizePolicy::_gc_cms_adaptive_size_policy,
       
   128       "Wrong size policy");
       
   129     return (CMSAdaptiveSizePolicy*)_size_policy;
       
   130   }
       
   131 
       
   132   inline void update_avg_cms_STW_time_counter() {
       
   133     _avg_cms_STW_time_counter->set_value(
       
   134       (jlong) (cms_size_policy()->avg_cms_STW_time()->average() *
       
   135       (double) MILLIUNITS));
       
   136   }
       
   137 
       
   138   inline void update_avg_cms_STW_gc_cost_counter() {
       
   139     _avg_cms_STW_gc_cost_counter->set_value(
       
   140       (jlong) (cms_size_policy()->avg_cms_STW_gc_cost()->average() * 100.0));
       
   141   }
       
   142 
       
   143   inline void update_avg_initial_pause_counter() {
       
   144     _avg_initial_pause_counter->set_value(
       
   145       (jlong) (cms_size_policy()->avg_initial_pause()->average() *
       
   146       (double) MILLIUNITS));
       
   147   }
       
   148 #ifdef NOT_PRODUCT
       
   149   inline void update_avg_remark_pause_counter() {
       
   150     _avg_remark_pause_counter->set_value(
       
   151       (jlong) (cms_size_policy()-> avg_remark_pause()->average() *
       
   152       (double) MILLIUNITS));
       
   153   }
       
   154 
       
   155   inline void update_initial_pause_counter() {
       
   156     _initial_pause_counter->set_value(
       
   157       (jlong) (cms_size_policy()->avg_initial_pause()->average() *
       
   158       (double) MILLIUNITS));
       
   159   }
       
   160 #endif
       
   161   inline void update_remark_pause_counter() {
       
   162     _remark_pause_counter->set_value(
       
   163       (jlong) (cms_size_policy()-> avg_remark_pause()->last_sample() *
       
   164       (double) MILLIUNITS));
       
   165   }
       
   166 
       
   167   inline void update_avg_concurrent_time_counter() {
       
   168     _avg_concurrent_time_counter->set_value(
       
   169       (jlong) (cms_size_policy()->avg_concurrent_time()->last_sample() *
       
   170       (double) MILLIUNITS));
       
   171   }
       
   172 
       
   173   inline void update_avg_concurrent_interval_counter() {
       
   174     _avg_concurrent_interval_counter->set_value(
       
   175       (jlong) (cms_size_policy()->avg_concurrent_interval()->average() *
       
   176       (double) MILLIUNITS));
       
   177   }
       
   178 
       
   179   inline void update_avg_concurrent_gc_cost_counter() {
       
   180     _avg_concurrent_gc_cost_counter->set_value(
       
   181       (jlong) (cms_size_policy()->avg_concurrent_gc_cost()->average() * 100.0));
       
   182   }
       
   183 
       
   184   inline void update_avg_cms_free_counter() {
       
   185     _avg_cms_free_counter->set_value(
       
   186       (jlong) cms_size_policy()->avg_cms_free()->average());
       
   187   }
       
   188 
       
   189   inline void update_avg_cms_free_at_sweep_counter() {
       
   190     _avg_cms_free_at_sweep_counter->set_value(
       
   191       (jlong) cms_size_policy()->avg_cms_free_at_sweep()->average());
       
   192   }
       
   193 
       
   194   inline void update_avg_cms_promo_counter() {
       
   195     _avg_cms_promo_counter->set_value(
       
   196       (jlong) cms_size_policy()->avg_cms_promo()->average());
       
   197   }
       
   198 
       
   199   inline void update_avg_old_live_counter() {
       
   200     _avg_old_live_counter->set_value(
       
   201       (jlong)(cms_size_policy()->avg_old_live()->average())
       
   202     );
       
   203   }
       
   204 
       
   205   inline void update_avg_msc_pause_counter() {
       
   206     _avg_msc_pause_counter->set_value(
       
   207       (jlong) (cms_size_policy()->avg_msc_pause()->average() *
       
   208       (double) MILLIUNITS));
       
   209   }
       
   210 
       
   211   inline void update_avg_msc_interval_counter() {
       
   212     _avg_msc_interval_counter->set_value(
       
   213       (jlong) (cms_size_policy()->avg_msc_interval()->average() *
       
   214       (double) MILLIUNITS));
       
   215   }
       
   216 
       
   217   inline void update_msc_gc_cost_counter() {
       
   218     _msc_gc_cost_counter->set_value(
       
   219       (jlong) (cms_size_policy()->avg_msc_gc_cost()->average() * 100.0));
       
   220   }
       
   221 
       
   222   inline void update_avg_ms_pause_counter() {
       
   223     _avg_ms_pause_counter->set_value(
       
   224       (jlong) (cms_size_policy()->avg_ms_pause()->average() *
       
   225       (double) MILLIUNITS));
       
   226   }
       
   227 
       
   228   inline void update_avg_ms_interval_counter() {
       
   229     _avg_ms_interval_counter->set_value(
       
   230       (jlong) (cms_size_policy()->avg_ms_interval()->average() *
       
   231       (double) MILLIUNITS));
       
   232   }
       
   233 
       
   234   inline void update_ms_gc_cost_counter() {
       
   235     _ms_gc_cost_counter->set_value(
       
   236       (jlong) (cms_size_policy()->avg_ms_gc_cost()->average() * 100.0));
       
   237   }
       
   238 
       
   239   inline void update_major_gc_cost_counter() {
       
   240     _major_gc_cost_counter->set_value(
       
   241       (jlong)(cms_size_policy()->cms_gc_cost() * 100.0)
       
   242     );
       
   243   }
       
   244   inline void update_mutator_cost_counter() {
       
   245     _mutator_cost_counter->set_value(
       
   246       (jlong)(cms_size_policy()->mutator_cost() * 100.0)
       
   247     );
       
   248   }
       
   249 
       
   250   inline void update_avg_promoted_avg(CMSGCStats* gc_stats) {
       
   251     _promoted_avg_counter->set_value(
       
   252       (jlong)(gc_stats->avg_promoted()->average())
       
   253     );
       
   254   }
       
   255   inline void update_avg_promoted_dev(CMSGCStats* gc_stats) {
       
   256     _promoted_avg_dev_counter->set_value(
       
   257       (jlong)(gc_stats->avg_promoted()->deviation())
       
   258     );
       
   259   }
       
   260   inline void update_avg_promoted_padded_avg(CMSGCStats* gc_stats) {
       
   261     _promoted_padded_avg_counter->set_value(
       
   262       (jlong)(gc_stats->avg_promoted()->padded_average())
       
   263     );
       
   264   }
       
   265   inline void update_remark_pause_old_slope_counter() {
       
   266     _remark_pause_old_slope_counter->set_value(
       
   267       (jlong)(cms_size_policy()->remark_pause_old_slope() * 1000)
       
   268     );
       
   269   }
       
   270   inline void update_initial_pause_old_slope_counter() {
       
   271     _initial_pause_old_slope_counter->set_value(
       
   272       (jlong)(cms_size_policy()->initial_pause_old_slope() * 1000)
       
   273     );
       
   274   }
       
   275   inline void update_remark_pause_young_slope_counter() {
       
   276     _remark_pause_young_slope_counter->set_value(
       
   277       (jlong)(cms_size_policy()->remark_pause_young_slope() * 1000)
       
   278     );
       
   279   }
       
   280   inline void update_initial_pause_young_slope_counter() {
       
   281     _initial_pause_young_slope_counter->set_value(
       
   282       (jlong)(cms_size_policy()->initial_pause_young_slope() * 1000)
       
   283     );
       
   284   }
       
   285   inline void update_change_young_gen_for_maj_pauses() {
       
   286     _change_young_gen_for_maj_pauses_counter->set_value(
       
   287       cms_size_policy()->change_young_gen_for_maj_pauses());
       
   288   }
       
   289 
       
   290  public:
       
   291   CMSGCAdaptivePolicyCounters(const char* name, int collectors, int generations,
       
   292                               AdaptiveSizePolicy* size_policy);
       
   293 
       
   294   // update counters
       
   295   void update_counters();
       
   296   void update_counters(CMSGCStats* gc_stats);
       
   297   void update_counters_from_policy();
       
   298 
       
   299   inline void update_cms_capacity_counter(size_t size_in_bytes) {
       
   300     _cms_capacity_counter->set_value(size_in_bytes);
       
   301   }
       
   302 
       
   303   virtual GCPolicyCounters::Name kind() const {
       
   304     return GCPolicyCounters::CMSGCAdaptivePolicyCountersKind;
       
   305   }
       
   306 };
       
   307 
       
   308 #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSGCADAPTIVEPOLICYCOUNTERS_HPP