aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp
blob: c68397056257c96acaf529b776ba2a4cacccad53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 *
 */

#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSGCADAPTIVEPOLICYCOUNTERS_HPP
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSGCADAPTIVEPOLICYCOUNTERS_HPP

#include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
#include "gc_implementation/shared/gcAdaptivePolicyCounters.hpp"
#include "gc_implementation/shared/gcPolicyCounters.hpp"

// PSGCAdaptivePolicyCounters is a holder class for performance counters
// that track the data and decisions for the ergonomics policy for the
// parallel scavenge collector.

class PSGCAdaptivePolicyCounters : public GCAdaptivePolicyCounters {
  friend class VMStructs;

 private:
  // survivor space vs. tenuring threshold
  PerfVariable* _old_promo_size;
  PerfVariable* _old_eden_size;
  PerfVariable* _avg_promoted_avg_counter;
  PerfVariable* _avg_promoted_dev_counter;
  PerfVariable* _avg_promoted_padded_avg_counter;
  PerfVariable* _avg_pretenured_padded_avg;

  // young gen vs. old gen sizing
  PerfVariable* _avg_major_pause;
  PerfVariable* _avg_major_interval;
  PerfVariable* _live_space;
  PerfVariable* _free_space;
  PerfVariable* _avg_base_footprint;
  PerfVariable* _gc_overhead_limit_exceeded_counter;
  PerfVariable* _live_at_last_full_gc_counter;
  PerfVariable* _old_capacity;
  PerfVariable* _boundary_moved;

  PerfVariable* _change_old_gen_for_min_pauses;
  PerfVariable* _change_young_gen_for_maj_pauses_counter;

  PerfVariable* _major_pause_old_slope;
  PerfVariable* _minor_pause_old_slope;
  PerfVariable* _major_pause_young_slope;

  PerfVariable* _scavenge_skipped;
  PerfVariable* _full_follows_scavenge;

  // Use this time stamp if the gc time stamp is not available.
  TimeStamp     _counter_time_stamp;

 protected:
  PSAdaptiveSizePolicy* ps_size_policy() {
    return (PSAdaptiveSizePolicy*)_size_policy;
  }

 public:
  PSGCAdaptivePolicyCounters(const char* name, int collectors, int generations,
                             PSAdaptiveSizePolicy* size_policy);
  inline void update_old_capacity(size_t size_in_bytes) {
    _old_capacity->set_value(size_in_bytes);
  }
  inline void update_old_eden_size(size_t old_size) {
    _old_eden_size->set_value(old_size);
  }
  inline void update_old_promo_size(size_t old_size) {
    _old_promo_size->set_value(old_size);
  }
  inline void update_boundary_moved(int size_in_bytes) {
    _boundary_moved->set_value(size_in_bytes);
  }
  inline void update_avg_promoted_avg() {
    _avg_promoted_avg_counter->set_value(
      (jlong)(ps_size_policy()->avg_promoted()->average())
    );
  }
  inline void update_avg_promoted_dev() {
    _avg_promoted_dev_counter->set_value(
      (jlong)(ps_size_policy()->avg_promoted()->deviation())
    );
  }
  inline void update_avg_promoted_padded_avg() {
    _avg_promoted_padded_avg_counter->set_value(
      (jlong)(ps_size_policy()->avg_promoted()->padded_average())
    );
  }

  inline void update_avg_pretenured_padded_avg() {
    _avg_pretenured_padded_avg->set_value(
      (jlong)(ps_size_policy()->_avg_pretenured->padded_average())
    );
  }
  inline void update_change_young_gen_for_maj_pauses() {
    _change_young_gen_for_maj_pauses_counter->set_value(
      ps_size_policy()->change_young_gen_for_maj_pauses());
  }
  inline void update_change_old_gen_for_min_pauses() {
    _change_old_gen_for_min_pauses->set_value(
      ps_size_policy()->change_old_gen_for_min_pauses());
  }

  // compute_generation_free_space() statistics

  inline void update_avg_major_pause() {
    _avg_major_pause->set_value(
      (jlong)(ps_size_policy()->_avg_major_pause->average() * 1000.0)
    );
  }
  inline void update_avg_major_interval() {
    _avg_major_interval->set_value(
      (jlong)(ps_size_policy()->_avg_major_interval->average() * 1000.0)
    );
  }

  inline void update_major_gc_cost_counter() {
    _major_gc_cost_counter->set_value(
      (jlong)(ps_size_policy()->major_gc_cost() * 100.0)
    );
  }
  inline void update_mutator_cost_counter() {
    _mutator_cost_counter->set_value(
      (jlong)(ps_size_policy()->mutator_cost() * 100.0)
    );
  }

  inline void update_live_space() {
    _live_space->set_value(ps_size_policy()->live_space());
  }
  inline void update_free_space() {
    _free_space->set_value(ps_size_policy()->free_space());
  }

  inline void update_avg_base_footprint() {
    _avg_base_footprint->set_value(
      (jlong)(ps_size_policy()->avg_base_footprint()->average())
    );
  }
  inline void update_avg_old_live() {
    _avg_old_live_counter->set_value(
      (jlong)(ps_size_policy()->avg_old_live()->average())
    );
  }
  // Scale up all the slopes
  inline void update_major_pause_old_slope() {
    _major_pause_old_slope->set_value(
      (jlong)(ps_size_policy()->major_pause_old_slope() * 1000)
    );
  }
  inline void update_minor_pause_old_slope() {
    _minor_pause_old_slope->set_value(
      (jlong)(ps_size_policy()->minor_pause_old_slope() * 1000)
    );
  }
  inline void update_major_pause_young_slope() {
    _major_pause_young_slope->set_value(
      (jlong)(ps_size_policy()->major_pause_young_slope() * 1000)
    );
  }
  inline void update_gc_overhead_limit_exceeded_counter() {
    _gc_overhead_limit_exceeded_counter->set_value(
      (jlong) ps_size_policy()->gc_overhead_limit_exceeded());
  }
  inline void update_live_at_last_full_gc_counter() {
    _live_at_last_full_gc_counter->set_value(
      (jlong)(ps_size_policy()->live_at_last_full_gc()));
  }

  inline void update_scavenge_skipped(int cause) {
    _scavenge_skipped->set_value(cause);
  }

  inline void update_full_follows_scavenge(int event) {
    _full_follows_scavenge->set_value(event);
  }

  // Update all the counters that can be updated from the size policy.
  // This should be called after all policy changes have been made
  // and reflected internall in the size policy.
  void update_counters_from_policy();

  // Update counters that can be updated from fields internal to the
  // counter or from globals.  This is distinguished from counters
  // that are updated via input parameters.
  void update_counters();

  virtual GCPolicyCounters::Name kind() const {
    return GCPolicyCounters::PSGCAdaptivePolicyCountersKind;
  }
};

#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSGCADAPTIVEPOLICYCOUNTERS_HPP