1 /*
2 * Copyright (c) 2013, 2014 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 *
141 template <> const size_t WorkerDataArray<size_t>::_uninitialized = (size_t)-1;
142
143 template <class T>
144 void WorkerDataArray<T>::reset() {
145 for (uint i = 0; i < _length; i++) {
146 _data[i] = (T)_uninitialized;
147 }
148 }
149
150 template <class T>
151 void WorkerDataArray<T>::verify() {
152 for (uint i = 0; i < _length; i++) {
153 assert(_data[i] != _uninitialized,
154 err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
155 i, (double)_data[i], (double)_uninitialized));
156 }
157 }
158
159 #endif
160
161 G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
162 _max_gc_threads(max_gc_threads),
163 _last_gc_worker_start_times_ms(_max_gc_threads, "%.1lf", false),
164 _last_ext_root_scan_times_ms(_max_gc_threads, "%.1lf"),
165 _last_satb_filtering_times_ms(_max_gc_threads, "%.1lf"),
166 _last_update_rs_times_ms(_max_gc_threads, "%.1lf"),
167 _last_update_rs_processed_buffers(_max_gc_threads, "%d"),
168 _last_scan_rs_times_ms(_max_gc_threads, "%.1lf"),
169 _last_strong_code_root_scan_times_ms(_max_gc_threads, "%.1lf"),
170 _last_obj_copy_times_ms(_max_gc_threads, "%.1lf"),
171 _last_termination_times_ms(_max_gc_threads, "%.1lf"),
172 _last_termination_attempts(_max_gc_threads, SIZE_FORMAT),
173 _last_gc_worker_end_times_ms(_max_gc_threads, "%.1lf", false),
174 _last_gc_worker_times_ms(_max_gc_threads, "%.1lf"),
175 _last_gc_worker_other_times_ms(_max_gc_threads, "%.1lf"),
176 _last_redirty_logged_cards_time_ms(_max_gc_threads, "%.1lf"),
177 _last_redirty_logged_cards_processed_cards(_max_gc_threads, SIZE_FORMAT),
178 _cur_string_dedup_queue_fixup_worker_times_ms(_max_gc_threads, "%.1lf"),
179 _cur_string_dedup_table_fixup_worker_times_ms(_max_gc_threads, "%.1lf")
180 {
181 assert(max_gc_threads > 0, "Must have some GC threads");
182 }
183
184 void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
185 assert(active_gc_threads > 0, "The number of threads must be > 0");
186 assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max nubmer of threads");
187 _active_gc_threads = active_gc_threads;
188
189 _last_gc_worker_start_times_ms.reset();
190 _last_ext_root_scan_times_ms.reset();
191 _last_satb_filtering_times_ms.reset();
192 _last_update_rs_times_ms.reset();
193 _last_update_rs_processed_buffers.reset();
194 _last_scan_rs_times_ms.reset();
195 _last_strong_code_root_scan_times_ms.reset();
196 _last_obj_copy_times_ms.reset();
197 _last_termination_times_ms.reset();
198 _last_termination_attempts.reset();
199 _last_gc_worker_end_times_ms.reset();
200 _last_gc_worker_times_ms.reset();
201 _last_gc_worker_other_times_ms.reset();
202
203 _last_redirty_logged_cards_time_ms.reset();
204 _last_redirty_logged_cards_processed_cards.reset();
205
206 }
207
208 void G1GCPhaseTimes::note_gc_end() {
209 _last_gc_worker_start_times_ms.verify();
210 _last_ext_root_scan_times_ms.verify();
211 _last_satb_filtering_times_ms.verify();
212 _last_update_rs_times_ms.verify();
213 _last_update_rs_processed_buffers.verify();
214 _last_scan_rs_times_ms.verify();
215 _last_strong_code_root_scan_times_ms.verify();
216 _last_obj_copy_times_ms.verify();
217 _last_termination_times_ms.verify();
218 _last_termination_attempts.verify();
219 _last_gc_worker_end_times_ms.verify();
220
221 for (uint i = 0; i < _active_gc_threads; i++) {
222 double worker_time = _last_gc_worker_end_times_ms.get(i) - _last_gc_worker_start_times_ms.get(i);
223 _last_gc_worker_times_ms.set(i, worker_time);
224
225 double worker_known_time = _last_ext_root_scan_times_ms.get(i) +
278
279 if (G1StringDedup::is_enabled()) {
280 // String dedup fixup time
281 misc_time_ms += _cur_string_dedup_fixup_time_ms;
282 }
283
284 // Subtract the time taken to clean the card table from the
285 // current value of "other time"
286 misc_time_ms += _cur_clear_ct_time_ms;
287
288 return misc_time_ms;
289 }
290
291 void G1GCPhaseTimes::print(double pause_time_sec) {
292 if (_root_region_scan_wait_time_ms > 0.0) {
293 print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
294 }
295 print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
296 _last_gc_worker_start_times_ms.print(2, "GC Worker Start (ms)");
297 _last_ext_root_scan_times_ms.print(2, "Ext Root Scanning (ms)");
298 if (_last_satb_filtering_times_ms.sum() > 0.0) {
299 _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)");
300 }
301 _last_update_rs_times_ms.print(2, "Update RS (ms)");
302 _last_update_rs_processed_buffers.print(3, "Processed Buffers");
303 _last_scan_rs_times_ms.print(2, "Scan RS (ms)");
304 _last_strong_code_root_scan_times_ms.print(2, "Code Root Scanning (ms)");
305 _last_obj_copy_times_ms.print(2, "Object Copy (ms)");
306 _last_termination_times_ms.print(2, "Termination (ms)");
307 if (G1Log::finest()) {
308 _last_termination_attempts.print(3, "Termination Attempts");
309 }
310 _last_gc_worker_other_times_ms.print(2, "GC Worker Other (ms)");
311 _last_gc_worker_times_ms.print(2, "GC Worker Total (ms)");
312 _last_gc_worker_end_times_ms.print(2, "GC Worker End (ms)");
313
314 print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
315 print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
316 if (G1StringDedup::is_enabled()) {
317 print_stats(1, "String Dedup Fixup", _cur_string_dedup_fixup_time_ms, _active_gc_threads);
|
1 /*
2 * Copyright (c) 2013, 2015 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 *
141 template <> const size_t WorkerDataArray<size_t>::_uninitialized = (size_t)-1;
142
143 template <class T>
144 void WorkerDataArray<T>::reset() {
145 for (uint i = 0; i < _length; i++) {
146 _data[i] = (T)_uninitialized;
147 }
148 }
149
150 template <class T>
151 void WorkerDataArray<T>::verify() {
152 for (uint i = 0; i < _length; i++) {
153 assert(_data[i] != _uninitialized,
154 err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
155 i, (double)_data[i], (double)_uninitialized));
156 }
157 }
158
159 #endif
160
161 G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads, uint num_ext_root_scan_phases) :
162 _max_gc_threads(max_gc_threads),
163 _num_ext_root_scan_phases(num_ext_root_scan_phases),
164 _last_gc_worker_start_times_ms(_max_gc_threads, "%.1lf", false),
165 _last_ext_root_scan_times_ms(_max_gc_threads, "%.1lf"),
166 _last_ext_root_scan_phase_times_ms(NULL),
167 _last_satb_filtering_times_ms(_max_gc_threads, "%.1lf"),
168 _last_update_rs_times_ms(_max_gc_threads, "%.1lf"),
169 _last_update_rs_processed_buffers(_max_gc_threads, "%d"),
170 _last_scan_rs_times_ms(_max_gc_threads, "%.1lf"),
171 _last_strong_code_root_scan_times_ms(_max_gc_threads, "%.1lf"),
172 _last_obj_copy_times_ms(_max_gc_threads, "%.1lf"),
173 _last_termination_times_ms(_max_gc_threads, "%.1lf"),
174 _last_termination_attempts(_max_gc_threads, SIZE_FORMAT),
175 _last_gc_worker_end_times_ms(_max_gc_threads, "%.1lf", false),
176 _last_gc_worker_times_ms(_max_gc_threads, "%.1lf"),
177 _last_gc_worker_other_times_ms(_max_gc_threads, "%.1lf"),
178 _last_redirty_logged_cards_time_ms(_max_gc_threads, "%.1lf"),
179 _last_redirty_logged_cards_processed_cards(_max_gc_threads, SIZE_FORMAT),
180 _cur_string_dedup_queue_fixup_worker_times_ms(_max_gc_threads, "%.1lf"),
181 _cur_string_dedup_table_fixup_worker_times_ms(_max_gc_threads, "%.1lf")
182 {
183 assert(max_gc_threads > 0, "Must have some GC threads");
184 if (track_ext_root_scan_phases()) {
185 _last_ext_root_scan_phase_times_ms = NEW_C_HEAP_ARRAY(WorkerDataArray<double>*, num_ext_root_scan_phases, mtGC);
186 for (uint i = 0; i < num_ext_root_scan_phases; i++) {
187 _last_ext_root_scan_phase_times_ms[i] = new WorkerDataArray<double>(_max_gc_threads, "%.1lf");
188 }
189 }
190 }
191
192 G1GCPhaseTimes::~G1GCPhaseTimes() {
193 if (track_ext_root_scan_phases()) {
194 for (uint i = 0; i < _num_ext_root_scan_phases; i++) {
195 delete _last_ext_root_scan_phase_times_ms[i];
196 }
197 FREE_C_HEAP_ARRAY(WorkerDataArray<double>*, _last_ext_root_scan_phase_times_ms);
198 }
199 }
200
201 void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
202 assert(active_gc_threads > 0, "The number of threads must be > 0");
203 assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max nubmer of threads");
204 _active_gc_threads = active_gc_threads;
205
206 _last_gc_worker_start_times_ms.reset();
207 _last_ext_root_scan_times_ms.reset();
208 _last_satb_filtering_times_ms.reset();
209 _last_update_rs_times_ms.reset();
210 _last_update_rs_processed_buffers.reset();
211 _last_scan_rs_times_ms.reset();
212 _last_strong_code_root_scan_times_ms.reset();
213 _last_obj_copy_times_ms.reset();
214 _last_termination_times_ms.reset();
215 _last_termination_attempts.reset();
216 _last_gc_worker_end_times_ms.reset();
217 _last_gc_worker_times_ms.reset();
218 _last_gc_worker_other_times_ms.reset();
219
220 _last_redirty_logged_cards_time_ms.reset();
221 _last_redirty_logged_cards_processed_cards.reset();
222
223 for (uint i = 0; i < _num_ext_root_scan_phases; i++) {
224 _last_ext_root_scan_phase_times_ms[i]->reset();
225 }
226 }
227
228 void G1GCPhaseTimes::note_gc_end() {
229 _last_gc_worker_start_times_ms.verify();
230 _last_ext_root_scan_times_ms.verify();
231 _last_satb_filtering_times_ms.verify();
232 _last_update_rs_times_ms.verify();
233 _last_update_rs_processed_buffers.verify();
234 _last_scan_rs_times_ms.verify();
235 _last_strong_code_root_scan_times_ms.verify();
236 _last_obj_copy_times_ms.verify();
237 _last_termination_times_ms.verify();
238 _last_termination_attempts.verify();
239 _last_gc_worker_end_times_ms.verify();
240
241 for (uint i = 0; i < _active_gc_threads; i++) {
242 double worker_time = _last_gc_worker_end_times_ms.get(i) - _last_gc_worker_start_times_ms.get(i);
243 _last_gc_worker_times_ms.set(i, worker_time);
244
245 double worker_known_time = _last_ext_root_scan_times_ms.get(i) +
298
299 if (G1StringDedup::is_enabled()) {
300 // String dedup fixup time
301 misc_time_ms += _cur_string_dedup_fixup_time_ms;
302 }
303
304 // Subtract the time taken to clean the card table from the
305 // current value of "other time"
306 misc_time_ms += _cur_clear_ct_time_ms;
307
308 return misc_time_ms;
309 }
310
311 void G1GCPhaseTimes::print(double pause_time_sec) {
312 if (_root_region_scan_wait_time_ms > 0.0) {
313 print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
314 }
315 print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
316 _last_gc_worker_start_times_ms.print(2, "GC Worker Start (ms)");
317 _last_ext_root_scan_times_ms.print(2, "Ext Root Scanning (ms)");
318 if (track_ext_root_scan_phases()) {
319 for (uint i = 0; i < _num_ext_root_scan_phases; i++) {
320 WorkerDataArray<double>* data = _last_ext_root_scan_phase_times_ms[i];
321 data->print(3, G1CollectedHeap::ext_roots_task_string(i));
322 }
323 }
324 if (_last_satb_filtering_times_ms.sum() > 0.0) {
325 _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)");
326 }
327 _last_update_rs_times_ms.print(2, "Update RS (ms)");
328 _last_update_rs_processed_buffers.print(3, "Processed Buffers");
329 _last_scan_rs_times_ms.print(2, "Scan RS (ms)");
330 _last_strong_code_root_scan_times_ms.print(2, "Code Root Scanning (ms)");
331 _last_obj_copy_times_ms.print(2, "Object Copy (ms)");
332 _last_termination_times_ms.print(2, "Termination (ms)");
333 if (G1Log::finest()) {
334 _last_termination_attempts.print(3, "Termination Attempts");
335 }
336 _last_gc_worker_other_times_ms.print(2, "GC Worker Other (ms)");
337 _last_gc_worker_times_ms.print(2, "GC Worker Total (ms)");
338 _last_gc_worker_end_times_ms.print(2, "GC Worker End (ms)");
339
340 print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
341 print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
342 if (G1StringDedup::is_enabled()) {
343 print_stats(1, "String Dedup Fixup", _cur_string_dedup_fixup_time_ms, _active_gc_threads);
|