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 *
35 #include "runtime/thread.inline.hpp"
36
37 class GetRSThreadVTimeClosure : public ThreadClosure {
38 private:
39 G1RemSetSummary* _summary;
40 uint _counter;
41
42 public:
43 GetRSThreadVTimeClosure(G1RemSetSummary * summary) : ThreadClosure(), _summary(summary), _counter(0) {
44 assert(_summary != NULL, "just checking");
45 }
46
47 virtual void do_thread(Thread* t) {
48 ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t;
49 _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
50 _counter++;
51 }
52 };
53
54 void G1RemSetSummary::update() {
55 _num_refined_cards = remset()->conc_refine_cards();
56 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
57 _num_processed_buf_mutator = dcqs.processed_buffers_mut();
58 _num_processed_buf_rs_threads = dcqs.processed_buffers_rs_thread();
59
60 _num_coarsenings = HeapRegionRemSet::n_coarsenings();
61
62 ConcurrentG1Refine * cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
63 if (_rs_threads_vtimes != NULL) {
64 GetRSThreadVTimeClosure p(this);
65 cg1r->worker_threads_do(&p);
66 }
67 set_sampling_thread_vtime(cg1r->sampling_thread()->vtime_accum());
68 }
69
70 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
71 assert(_rs_threads_vtimes != NULL, "just checking");
72 assert(thread < _num_vtimes, "just checking");
73 _rs_threads_vtimes[thread] = value;
74 }
75
76 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
77 assert(_rs_threads_vtimes != NULL, "just checking");
78 assert(thread < _num_vtimes, "just checking");
79 return _rs_threads_vtimes[thread];
80 }
81
82 void G1RemSetSummary::initialize(G1RemSet* remset) {
83 assert(_rs_threads_vtimes == NULL, "just checking");
84 assert(remset != NULL, "just checking");
85
86 _remset = remset;
87 _num_vtimes = ConcurrentG1Refine::thread_num();
88 _rs_threads_vtimes = NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC);
89 memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
90
91 update();
92 }
93
94 G1RemSetSummary::G1RemSetSummary() :
95 _remset(NULL),
96 _num_refined_cards(0),
97 _num_processed_buf_mutator(0),
98 _num_processed_buf_rs_threads(0),
99 _num_coarsenings(0),
100 _rs_threads_vtimes(NULL),
101 _num_vtimes(0),
102 _sampling_thread_vtime(0.0f) {
103 }
104
105 G1RemSetSummary::~G1RemSetSummary() {
106 if (_rs_threads_vtimes) {
107 FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
108 }
109 }
110
111 void G1RemSetSummary::set(G1RemSetSummary* other) {
112 assert(other != NULL, "just checking");
113 assert(remset() == other->remset(), "just checking");
114 assert(_num_vtimes == other->_num_vtimes, "just checking");
115
116 _num_refined_cards = other->num_concurrent_refined_cards();
117
118 _num_processed_buf_mutator = other->num_processed_buf_mutator();
119 _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads();
120
121 _num_coarsenings = other->_num_coarsenings;
122
123 memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
124
125 set_sampling_thread_vtime(other->sampling_thread_vtime());
126 }
127
128 void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
129 assert(other != NULL, "just checking");
130 assert(remset() == other->remset(), "just checking");
131 assert(_num_vtimes == other->_num_vtimes, "just checking");
132
133 _num_refined_cards = other->num_concurrent_refined_cards() - _num_refined_cards;
134
135 _num_processed_buf_mutator = other->num_processed_buf_mutator() - _num_processed_buf_mutator;
136 _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads() - _num_processed_buf_rs_threads;
137
138 _num_coarsenings = other->num_coarsenings() - _num_coarsenings;
139
140 for (uint i = 0; i < _num_vtimes; i++) {
141 set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
142 }
143
144 _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;
145 }
146
147 class RegionTypeCounter VALUE_OBJ_CLASS_SPEC {
148 private:
149 const char* _name;
150
151 size_t _rs_mem_size;
152 size_t _cards_occupied;
153 size_t _amount;
335 (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz());
336 }
337
338 out->print_cr(" " SIZE_FORMAT " code roots represented.",
339 total_code_root_elems());
340 for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
341 (*current)->print_code_root_elems_info_on(out, total_code_root_elems());
342 }
343
344 out->print_cr(" Region with largest amount of code roots = " HR_FORMAT ", "
345 "size = " SIZE_FORMAT "%s, num_elems = " SIZE_FORMAT ".",
346 HR_FORMAT_PARAMS(max_code_root_mem_sz_region()),
347 byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
348 proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()),
349 max_code_root_rem_set->strong_code_roots_list_length());
350 }
351 };
352
353 void G1RemSetSummary::print_on(outputStream* out) {
354 out->print_cr(" Recent concurrent refinement statistics");
355 out->print_cr(" Processed " SIZE_FORMAT " cards",
356 num_concurrent_refined_cards());
357 out->print_cr(" Of " SIZE_FORMAT " completed buffers:", num_processed_buf_total());
358 out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by concurrent RS threads.",
359 num_processed_buf_total(),
360 percent_of(num_processed_buf_rs_threads(), num_processed_buf_total()));
361 out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by mutator threads.",
362 num_processed_buf_mutator(),
363 percent_of(num_processed_buf_mutator(), num_processed_buf_total()));
364 out->print_cr(" Did " SIZE_FORMAT " coarsenings.", num_coarsenings());
365 out->print_cr(" Concurrent RS threads times (s)");
366 out->print(" ");
367 for (uint i = 0; i < _num_vtimes; i++) {
368 out->print(" %5.2f", rs_thread_vtime(i));
369 }
370 out->cr();
371 out->print_cr(" Concurrent sampling threads times (s)");
372 out->print_cr(" %5.2f", sampling_thread_vtime());
373
374 HRRSStatsIter blk;
375 G1CollectedHeap::heap()->heap_region_iterate(&blk);
376 blk.print_summary_on(out);
|
1 /*
2 * Copyright (c) 2013, 2017, 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 *
35 #include "runtime/thread.inline.hpp"
36
37 class GetRSThreadVTimeClosure : public ThreadClosure {
38 private:
39 G1RemSetSummary* _summary;
40 uint _counter;
41
42 public:
43 GetRSThreadVTimeClosure(G1RemSetSummary * summary) : ThreadClosure(), _summary(summary), _counter(0) {
44 assert(_summary != NULL, "just checking");
45 }
46
47 virtual void do_thread(Thread* t) {
48 ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t;
49 _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
50 _counter++;
51 }
52 };
53
54 void G1RemSetSummary::update() {
55 _num_conc_refined_cards = remset()->num_conc_refined_cards();
56 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
57 _num_processed_buf_mutator = dcqs.processed_buffers_mut();
58 _num_processed_buf_rs_threads = dcqs.processed_buffers_rs_thread();
59
60 _num_coarsenings = HeapRegionRemSet::n_coarsenings();
61
62 ConcurrentG1Refine * cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
63 if (_rs_threads_vtimes != NULL) {
64 GetRSThreadVTimeClosure p(this);
65 cg1r->worker_threads_do(&p);
66 }
67 set_sampling_thread_vtime(cg1r->sampling_thread()->vtime_accum());
68 }
69
70 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
71 assert(_rs_threads_vtimes != NULL, "just checking");
72 assert(thread < _num_vtimes, "just checking");
73 _rs_threads_vtimes[thread] = value;
74 }
75
76 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
77 assert(_rs_threads_vtimes != NULL, "just checking");
78 assert(thread < _num_vtimes, "just checking");
79 return _rs_threads_vtimes[thread];
80 }
81
82 void G1RemSetSummary::initialize(G1RemSet* remset) {
83 assert(_rs_threads_vtimes == NULL, "just checking");
84 assert(remset != NULL, "just checking");
85
86 _remset = remset;
87 _num_vtimes = ConcurrentG1Refine::thread_num();
88 _rs_threads_vtimes = NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC);
89 memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
90
91 update();
92 }
93
94 G1RemSetSummary::G1RemSetSummary() :
95 _remset(NULL),
96 _num_conc_refined_cards(0),
97 _num_processed_buf_mutator(0),
98 _num_processed_buf_rs_threads(0),
99 _num_coarsenings(0),
100 _rs_threads_vtimes(NULL),
101 _num_vtimes(0),
102 _sampling_thread_vtime(0.0f) {
103 }
104
105 G1RemSetSummary::~G1RemSetSummary() {
106 if (_rs_threads_vtimes) {
107 FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
108 }
109 }
110
111 void G1RemSetSummary::set(G1RemSetSummary* other) {
112 assert(other != NULL, "just checking");
113 assert(remset() == other->remset(), "just checking");
114 assert(_num_vtimes == other->_num_vtimes, "just checking");
115
116 _num_conc_refined_cards = other->num_conc_refined_cards();
117
118 _num_processed_buf_mutator = other->num_processed_buf_mutator();
119 _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads();
120
121 _num_coarsenings = other->_num_coarsenings;
122
123 memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
124
125 set_sampling_thread_vtime(other->sampling_thread_vtime());
126 }
127
128 void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
129 assert(other != NULL, "just checking");
130 assert(remset() == other->remset(), "just checking");
131 assert(_num_vtimes == other->_num_vtimes, "just checking");
132
133 _num_conc_refined_cards = other->num_conc_refined_cards() - _num_conc_refined_cards;
134
135 _num_processed_buf_mutator = other->num_processed_buf_mutator() - _num_processed_buf_mutator;
136 _num_processed_buf_rs_threads = other->num_processed_buf_rs_threads() - _num_processed_buf_rs_threads;
137
138 _num_coarsenings = other->num_coarsenings() - _num_coarsenings;
139
140 for (uint i = 0; i < _num_vtimes; i++) {
141 set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
142 }
143
144 _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;
145 }
146
147 class RegionTypeCounter VALUE_OBJ_CLASS_SPEC {
148 private:
149 const char* _name;
150
151 size_t _rs_mem_size;
152 size_t _cards_occupied;
153 size_t _amount;
335 (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz());
336 }
337
338 out->print_cr(" " SIZE_FORMAT " code roots represented.",
339 total_code_root_elems());
340 for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
341 (*current)->print_code_root_elems_info_on(out, total_code_root_elems());
342 }
343
344 out->print_cr(" Region with largest amount of code roots = " HR_FORMAT ", "
345 "size = " SIZE_FORMAT "%s, num_elems = " SIZE_FORMAT ".",
346 HR_FORMAT_PARAMS(max_code_root_mem_sz_region()),
347 byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()),
348 proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()),
349 max_code_root_rem_set->strong_code_roots_list_length());
350 }
351 };
352
353 void G1RemSetSummary::print_on(outputStream* out) {
354 out->print_cr(" Recent concurrent refinement statistics");
355 out->print_cr(" Processed " SIZE_FORMAT " cards concurrently", num_conc_refined_cards());
356 out->print_cr(" Of " SIZE_FORMAT " completed buffers:", num_processed_buf_total());
357 out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by concurrent RS threads.",
358 num_processed_buf_total(),
359 percent_of(num_processed_buf_rs_threads(), num_processed_buf_total()));
360 out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by mutator threads.",
361 num_processed_buf_mutator(),
362 percent_of(num_processed_buf_mutator(), num_processed_buf_total()));
363 out->print_cr(" Did " SIZE_FORMAT " coarsenings.", num_coarsenings());
364 out->print_cr(" Concurrent RS threads times (s)");
365 out->print(" ");
366 for (uint i = 0; i < _num_vtimes; i++) {
367 out->print(" %5.2f", rs_thread_vtime(i));
368 }
369 out->cr();
370 out->print_cr(" Concurrent sampling threads times (s)");
371 out->print_cr(" %5.2f", sampling_thread_vtime());
372
373 HRRSStatsIter blk;
374 G1CollectedHeap::heap()->heap_region_iterate(&blk);
375 blk.print_summary_on(out);
|