author | ehelin |
Tue, 18 Mar 2014 09:03:28 +0100 | |
changeset 23470 | ff2a7ea4225d |
parent 21767 | 41eaa9a17059 |
child 25350 | 6423a57e5451 |
permissions | -rw-r--r-- |
18025 | 1 |
/* |
2 |
* Copyright (c) 2012, 2013, 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 |
#include "precompiled.hpp" |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
26 |
#include "gc_implementation/shared/copyFailedInfo.hpp" |
18025 | 27 |
#include "gc_implementation/shared/gcHeapSummary.hpp" |
28 |
#include "gc_implementation/shared/gcTimer.hpp" |
|
29 |
#include "gc_implementation/shared/gcTrace.hpp" |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
30 |
#include "gc_implementation/shared/objectCountEventSender.hpp" |
18025 | 31 |
#include "memory/heapInspection.hpp" |
32 |
#include "memory/referenceProcessorStats.hpp" |
|
18706
2d278f82253d
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
18705
diff
changeset
|
33 |
#include "runtime/os.hpp" |
18025 | 34 |
#include "utilities/globalDefinitions.hpp" |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
35 |
#include "utilities/ticks.inline.hpp" |
18025 | 36 |
|
37 |
#if INCLUDE_ALL_GCS |
|
38 |
#include "gc_implementation/g1/evacuationInfo.hpp" |
|
39 |
#endif |
|
40 |
||
41 |
#define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?") |
|
42 |
#define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?") |
|
43 |
||
18705
8ab1fa795124
8016170: GC id variable in gcTrace.cpp should use typedef GCId
ehelin
parents:
18704
diff
changeset
|
44 |
static GCId GCTracer_next_gc_id = 0; |
18025 | 45 |
static GCId create_new_gc_id() { |
46 |
return GCTracer_next_gc_id++; |
|
47 |
} |
|
48 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
49 |
void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) { |
18025 | 50 |
assert_unset_gc_id(); |
51 |
||
52 |
GCId gc_id = create_new_gc_id(); |
|
53 |
_shared_gc_info.set_id(gc_id); |
|
54 |
_shared_gc_info.set_cause(cause); |
|
55 |
_shared_gc_info.set_start_timestamp(timestamp); |
|
56 |
} |
|
57 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
58 |
void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) { |
18025 | 59 |
assert_unset_gc_id(); |
60 |
||
61 |
report_gc_start_impl(cause, timestamp); |
|
62 |
} |
|
63 |
||
64 |
bool GCTracer::has_reported_gc_start() const { |
|
65 |
return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID; |
|
66 |
} |
|
67 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
68 |
void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
18025 | 69 |
assert_set_gc_id(); |
70 |
||
71 |
_shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses()); |
|
72 |
_shared_gc_info.set_longest_pause(time_partitions->longest_pause()); |
|
73 |
_shared_gc_info.set_end_timestamp(timestamp); |
|
74 |
||
75 |
send_phase_events(time_partitions); |
|
76 |
send_garbage_collection_event(); |
|
77 |
} |
|
78 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
79 |
void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) { |
18025 | 80 |
assert_set_gc_id(); |
81 |
||
82 |
report_gc_end_impl(timestamp, time_partitions); |
|
83 |
||
84 |
_shared_gc_info.set_id(SharedGCInfo::UNSET_GCID); |
|
85 |
} |
|
86 |
||
87 |
void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const { |
|
88 |
assert_set_gc_id(); |
|
89 |
||
90 |
send_reference_stats_event(REF_SOFT, rps.soft_count()); |
|
91 |
send_reference_stats_event(REF_WEAK, rps.weak_count()); |
|
92 |
send_reference_stats_event(REF_FINAL, rps.final_count()); |
|
93 |
send_reference_stats_event(REF_PHANTOM, rps.phantom_count()); |
|
94 |
} |
|
95 |
||
96 |
#if INCLUDE_SERVICES |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
97 |
class ObjectCountEventSenderClosure : public KlassInfoClosure { |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
98 |
const GCId _gc_id; |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
99 |
const double _size_threshold_percentage; |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
100 |
const size_t _total_size_in_words; |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
101 |
const Ticks _timestamp; |
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
102 |
|
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
103 |
public: |
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
104 |
ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, const Ticks& timestamp) : |
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
105 |
_gc_id(gc_id), |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
106 |
_size_threshold_percentage(ObjectCountCutOffPercent / 100), |
18706
2d278f82253d
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
18705
diff
changeset
|
107 |
_total_size_in_words(total_size_in_words), |
2d278f82253d
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
18705
diff
changeset
|
108 |
_timestamp(timestamp) |
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
109 |
{} |
18025 | 110 |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
111 |
virtual void do_cinfo(KlassInfoEntry* entry) { |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
112 |
if (should_send_event(entry)) { |
18706
2d278f82253d
8015683: object_count_after_gc should have the same timestamp for all events
ehelin
parents:
18705
diff
changeset
|
113 |
ObjectCountEventSender::send(entry, _gc_id, _timestamp); |
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
114 |
} |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
115 |
} |
18025 | 116 |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
117 |
private: |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
118 |
bool should_send_event(const KlassInfoEntry* entry) const { |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
119 |
double percentage_of_heap = ((double) entry->words()) / _total_size_in_words; |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
120 |
return percentage_of_heap >= _size_threshold_percentage; |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
121 |
} |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
122 |
}; |
18025 | 123 |
|
124 |
void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) { |
|
125 |
assert_set_gc_id(); |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
126 |
assert(is_alive_cl != NULL, "Must supply function to check liveness"); |
18025 | 127 |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
128 |
if (ObjectCountEventSender::should_send_event()) { |
18025 | 129 |
ResourceMark rm; |
130 |
||
131 |
KlassInfoTable cit(false); |
|
132 |
if (!cit.allocation_failed()) { |
|
133 |
HeapInspection hi(false, false, false, NULL); |
|
134 |
hi.populate_table(&cit, is_alive_cl); |
|
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
135 |
ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), Ticks::now()); |
18025 | 136 |
cit.iterate(&event_sender); |
137 |
} |
|
138 |
} |
|
139 |
} |
|
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
140 |
#endif // INCLUDE_SERVICES |
18025 | 141 |
|
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
142 |
void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const { |
18025 | 143 |
assert_set_gc_id(); |
144 |
||
145 |
send_gc_heap_summary_event(when, heap_summary); |
|
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
146 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
147 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
148 |
void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
149 |
assert_set_gc_id(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
150 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
151 |
send_meta_space_summary_event(when, summary); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
152 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
153 |
send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary()); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
154 |
if (UseCompressedClassPointers) { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
155 |
send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary()); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
21767
diff
changeset
|
156 |
} |
18025 | 157 |
} |
158 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
159 |
void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
18025 | 160 |
assert_set_gc_id(); |
161 |
assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported"); |
|
162 |
||
163 |
GCTracer::report_gc_end_impl(timestamp, time_partitions); |
|
164 |
send_young_gc_event(); |
|
165 |
||
166 |
_tenuring_threshold = UNSET_TENURING_THRESHOLD; |
|
167 |
} |
|
168 |
||
169 |
void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) { |
|
170 |
assert_set_gc_id(); |
|
171 |
||
172 |
send_promotion_failed_event(pf_info); |
|
173 |
} |
|
174 |
||
175 |
void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) { |
|
176 |
_tenuring_threshold = tenuring_threshold; |
|
177 |
} |
|
178 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
179 |
void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
18025 | 180 |
assert_set_gc_id(); |
181 |
||
182 |
GCTracer::report_gc_end_impl(timestamp, time_partitions); |
|
183 |
send_old_gc_event(); |
|
184 |
} |
|
185 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
186 |
void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
18025 | 187 |
assert_set_gc_id(); |
188 |
||
189 |
OldGCTracer::report_gc_end_impl(timestamp, time_partitions); |
|
190 |
send_parallel_old_event(); |
|
191 |
} |
|
192 |
||
193 |
void ParallelOldTracer::report_dense_prefix(void* dense_prefix) { |
|
194 |
assert_set_gc_id(); |
|
195 |
||
196 |
_parallel_old_gc_info.report_dense_prefix(dense_prefix); |
|
197 |
} |
|
198 |
||
199 |
void OldGCTracer::report_concurrent_mode_failure() { |
|
200 |
assert_set_gc_id(); |
|
201 |
||
202 |
send_concurrent_mode_failure_event(); |
|
203 |
} |
|
204 |
||
205 |
#if INCLUDE_ALL_GCS |
|
206 |
void G1NewTracer::report_yc_type(G1YCType type) { |
|
207 |
assert_set_gc_id(); |
|
208 |
||
209 |
_g1_young_gc_info.set_type(type); |
|
210 |
} |
|
211 |
||
21767
41eaa9a17059
8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
18706
diff
changeset
|
212 |
void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
18025 | 213 |
assert_set_gc_id(); |
214 |
||
215 |
YoungGCTracer::report_gc_end_impl(timestamp, time_partitions); |
|
216 |
send_g1_young_gc_event(); |
|
217 |
} |
|
218 |
||
219 |
void G1NewTracer::report_evacuation_info(EvacuationInfo* info) { |
|
220 |
assert_set_gc_id(); |
|
221 |
||
222 |
send_evacuation_info_event(info); |
|
223 |
} |
|
224 |
||
225 |
void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) { |
|
226 |
assert_set_gc_id(); |
|
227 |
||
228 |
send_evacuation_failed_event(ef_info); |
|
229 |
ef_info.reset(); |
|
230 |
} |
|
231 |
#endif |