g1GCPhaseTimes.hpp revision 12408:777aaa19c4b1
1/*
2 * Copyright (c) 2013, 2016, 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_G1_G1GCPHASETIMES_HPP
26#define SHARE_VM_GC_G1_G1GCPHASETIMES_HPP
27
28#include "logging/logLevel.hpp"
29#include "memory/allocation.hpp"
30
31class LineBuffer;
32
33template <class T> class WorkerDataArray;
34
35class G1GCPhaseTimes : public CHeapObj<mtGC> {
36  uint _max_gc_threads;
37  jlong _gc_start_counter;
38  double _gc_pause_time_ms;
39
40 public:
41  enum GCParPhases {
42    GCWorkerStart,
43    ExtRootScan,
44    ThreadRoots,
45    StringTableRoots,
46    UniverseRoots,
47    JNIRoots,
48    ObjectSynchronizerRoots,
49    FlatProfilerRoots,
50    ManagementRoots,
51    SystemDictionaryRoots,
52    CLDGRoots,
53    JVMTIRoots,
54    CMRefRoots,
55    WaitForStrongCLD,
56    WeakCLDRoots,
57    SATBFiltering,
58    UpdateRS,
59    ScanHCC,
60    ScanRS,
61    CodeRoots,
62#if INCLUDE_AOT
63    AOTCodeRoots,
64#endif
65    ObjCopy,
66    Termination,
67    Other,
68    GCWorkerTotal,
69    GCWorkerEnd,
70    StringDedupQueueFixup,
71    StringDedupTableFixup,
72    RedirtyCards,
73    PreserveCMReferents,
74    YoungFreeCSet,
75    NonYoungFreeCSet,
76    GCParPhasesSentinel
77  };
78
79 private:
80  // Markers for grouping the phases in the GCPhases enum above
81  static const int GCMainParPhasesLast = GCWorkerEnd;
82  static const int StringDedupPhasesFirst = StringDedupQueueFixup;
83  static const int StringDedupPhasesLast = StringDedupTableFixup;
84
85  WorkerDataArray<double>* _gc_par_phases[GCParPhasesSentinel];
86  WorkerDataArray<size_t>* _update_rs_processed_buffers;
87  WorkerDataArray<size_t>* _termination_attempts;
88  WorkerDataArray<size_t>* _redirtied_cards;
89
90  double _cur_collection_par_time_ms;
91  double _cur_collection_code_root_fixup_time_ms;
92  double _cur_strong_code_root_purge_time_ms;
93
94  double _cur_evac_fail_recalc_used;
95  double _cur_evac_fail_restore_remsets;
96  double _cur_evac_fail_remove_self_forwards;
97
98  double _cur_string_dedup_fixup_time_ms;
99
100  double _cur_clear_ct_time_ms;
101  double _cur_expand_heap_time_ms;
102  double _cur_ref_proc_time_ms;
103  double _cur_ref_enq_time_ms;
104
105  double _cur_collection_start_sec;
106  double _root_region_scan_wait_time_ms;
107
108  double _external_accounted_time_ms;
109
110  double _recorded_clear_claimed_marks_time_ms;
111
112  double _recorded_young_cset_choice_time_ms;
113  double _recorded_non_young_cset_choice_time_ms;
114
115  double _recorded_redirty_logged_cards_time_ms;
116
117  double _recorded_preserve_cm_referents_time_ms;
118
119  double _recorded_merge_pss_time_ms;
120
121  double _recorded_total_free_cset_time_ms;
122
123  double _recorded_serial_free_cset_time_ms;
124
125  double _cur_fast_reclaim_humongous_time_ms;
126  double _cur_fast_reclaim_humongous_register_time_ms;
127  size_t _cur_fast_reclaim_humongous_total;
128  size_t _cur_fast_reclaim_humongous_candidates;
129  size_t _cur_fast_reclaim_humongous_reclaimed;
130
131  double _cur_verify_before_time_ms;
132  double _cur_verify_after_time_ms;
133
134  double worker_time(GCParPhases phase, uint worker);
135  void note_gc_end();
136  void reset();
137
138  template <class T>
139  void details(T* phase, const char* indent) const;
140
141  void log_phase(WorkerDataArray<double>* phase, uint indent, outputStream* out, bool print_sum) const;
142  void debug_phase(WorkerDataArray<double>* phase) const;
143  void trace_phase(WorkerDataArray<double>* phase, bool print_sum = true) const;
144
145  void info_time(const char* name, double value) const;
146  void debug_time(const char* name, double value) const;
147  void trace_time(const char* name, double value) const;
148  void trace_count(const char* name, size_t value) const;
149
150  double print_pre_evacuate_collection_set() const;
151  double print_evacuate_collection_set() const;
152  double print_post_evacuate_collection_set() const;
153  void print_other(double accounted_ms) const;
154
155 public:
156  G1GCPhaseTimes(uint max_gc_threads);
157  void note_gc_start();
158  void print();
159
160  // record the time a phase took in seconds
161  void record_time_secs(GCParPhases phase, uint worker_i, double secs);
162
163  // add a number of seconds to a phase
164  void add_time_secs(GCParPhases phase, uint worker_i, double secs);
165
166  void record_thread_work_item(GCParPhases phase, uint worker_i, size_t count);
167
168  // return the average time for a phase in milliseconds
169  double average_time_ms(GCParPhases phase);
170
171  size_t sum_thread_work_items(GCParPhases phase);
172
173 public:
174
175  void record_clear_ct_time(double ms) {
176    _cur_clear_ct_time_ms = ms;
177  }
178
179  void record_expand_heap_time(double ms) {
180    _cur_expand_heap_time_ms = ms;
181  }
182
183  void record_par_time(double ms) {
184    _cur_collection_par_time_ms = ms;
185  }
186
187  void record_code_root_fixup_time(double ms) {
188    _cur_collection_code_root_fixup_time_ms = ms;
189  }
190
191  void record_strong_code_root_purge_time(double ms) {
192    _cur_strong_code_root_purge_time_ms = ms;
193  }
194
195  void record_evac_fail_recalc_used_time(double ms) {
196    _cur_evac_fail_recalc_used = ms;
197  }
198
199  void record_evac_fail_restore_remsets(double ms) {
200    _cur_evac_fail_restore_remsets = ms;
201  }
202
203  void record_evac_fail_remove_self_forwards(double ms) {
204    _cur_evac_fail_remove_self_forwards = ms;
205  }
206
207  void record_string_dedup_fixup_time(double ms) {
208    _cur_string_dedup_fixup_time_ms = ms;
209  }
210
211  void record_ref_proc_time(double ms) {
212    _cur_ref_proc_time_ms = ms;
213  }
214
215  void record_ref_enq_time(double ms) {
216    _cur_ref_enq_time_ms = ms;
217  }
218
219  void record_root_region_scan_wait_time(double time_ms) {
220    _root_region_scan_wait_time_ms = time_ms;
221  }
222
223  void record_total_free_cset_time_ms(double time_ms) {
224    _recorded_total_free_cset_time_ms = time_ms;
225  }
226
227  void record_serial_free_cset_time_ms(double time_ms) {
228    _recorded_serial_free_cset_time_ms = time_ms;
229  }
230
231  void record_fast_reclaim_humongous_stats(double time_ms, size_t total, size_t candidates) {
232    _cur_fast_reclaim_humongous_register_time_ms = time_ms;
233    _cur_fast_reclaim_humongous_total = total;
234    _cur_fast_reclaim_humongous_candidates = candidates;
235  }
236
237  void record_fast_reclaim_humongous_time_ms(double value, size_t reclaimed) {
238    _cur_fast_reclaim_humongous_time_ms = value;
239    _cur_fast_reclaim_humongous_reclaimed = reclaimed;
240  }
241
242  void record_young_cset_choice_time_ms(double time_ms) {
243    _recorded_young_cset_choice_time_ms = time_ms;
244  }
245
246  void record_non_young_cset_choice_time_ms(double time_ms) {
247    _recorded_non_young_cset_choice_time_ms = time_ms;
248  }
249
250  void record_redirty_logged_cards_time_ms(double time_ms) {
251    _recorded_redirty_logged_cards_time_ms = time_ms;
252  }
253
254  void record_preserve_cm_referents_time_ms(double time_ms) {
255    _recorded_preserve_cm_referents_time_ms = time_ms;
256  }
257
258  void record_merge_pss_time_ms(double time_ms) {
259    _recorded_merge_pss_time_ms = time_ms;
260  }
261
262  void record_cur_collection_start_sec(double time_ms) {
263    _cur_collection_start_sec = time_ms;
264  }
265
266  void record_verify_before_time_ms(double time_ms) {
267    _cur_verify_before_time_ms = time_ms;
268  }
269
270  void record_verify_after_time_ms(double time_ms) {
271    _cur_verify_after_time_ms = time_ms;
272  }
273
274  void inc_external_accounted_time_ms(double time_ms) {
275    _external_accounted_time_ms += time_ms;
276  }
277
278  void record_clear_claimed_marks_time_ms(double recorded_clear_claimed_marks_time_ms) {
279    _recorded_clear_claimed_marks_time_ms = recorded_clear_claimed_marks_time_ms;
280  }
281
282  double cur_collection_start_sec() {
283    return _cur_collection_start_sec;
284  }
285
286  double cur_collection_par_time_ms() {
287    return _cur_collection_par_time_ms;
288  }
289
290  double cur_clear_ct_time_ms() {
291    return _cur_clear_ct_time_ms;
292  }
293
294  double cur_expand_heap_time_ms() {
295    return _cur_expand_heap_time_ms;
296  }
297
298  double root_region_scan_wait_time_ms() {
299    return _root_region_scan_wait_time_ms;
300  }
301
302  double young_cset_choice_time_ms() {
303    return _recorded_young_cset_choice_time_ms;
304  }
305
306  double total_free_cset_time_ms() {
307    return _recorded_total_free_cset_time_ms;
308  }
309
310  double non_young_cset_choice_time_ms() {
311    return _recorded_non_young_cset_choice_time_ms;
312  }
313
314  double fast_reclaim_humongous_time_ms() {
315    return _cur_fast_reclaim_humongous_time_ms;
316  }
317};
318
319class G1GCParPhaseTimesTracker : public StackObj {
320  double _start_time;
321  G1GCPhaseTimes::GCParPhases _phase;
322  G1GCPhaseTimes* _phase_times;
323  uint _worker_id;
324public:
325  G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id);
326  ~G1GCParPhaseTimesTracker();
327};
328
329#endif // SHARE_VM_GC_G1_G1GCPHASETIMES_HPP
330