Print this page
rev 4524 : 8012086: The object count event should only send events for instances occupying more than 0.5% of the heap
Reviewed-by: brutisso, jwilhelm
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/gc_implementation/shared/gcTrace.cpp
+++ new/src/share/vm/gc_implementation/shared/gcTrace.cpp
1 1 /*
2 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #include "precompiled.hpp"
26 26 #include "gc_implementation/shared/gcHeapSummary.hpp"
27 27 #include "gc_implementation/shared/gcTimer.hpp"
28 28 #include "gc_implementation/shared/gcTrace.hpp"
29 29 #include "gc_implementation/shared/copyFailedInfo.hpp"
30 30 #include "memory/heapInspection.hpp"
31 31 #include "memory/iterator.hpp"
32 32 #include "memory/referenceProcessorStats.hpp"
33 33 #include "utilities/globalDefinitions.hpp"
34 34
35 35 #ifndef SERIALGC
36 36 #include "gc_implementation/g1/evacuationInfo.hpp"
37 37 #endif
38 38
39 39 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
40 40 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
41 41
42 42 static jlong GCTracer_next_gc_id = 0;
43 43 static GCId create_new_gc_id() {
44 44 return GCTracer_next_gc_id++;
45 45 }
46 46
47 47 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {
48 48 assert_unset_gc_id();
49 49
50 50 GCId gc_id = create_new_gc_id();
51 51 _shared_gc_info.set_id(gc_id);
52 52 _shared_gc_info.set_cause(cause);
53 53 _shared_gc_info.set_start_timestamp(timestamp);
54 54 }
55 55
56 56 void GCTracer::report_gc_start(GCCause::Cause cause, jlong timestamp) {
57 57 assert_unset_gc_id();
58 58
59 59 report_gc_start_impl(cause, timestamp);
60 60 }
61 61
62 62 bool GCTracer::has_reported_gc_start() const {
63 63 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
64 64 }
65 65
66 66 void GCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
67 67 assert_set_gc_id();
68 68
69 69 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
70 70 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
71 71 _shared_gc_info.set_end_timestamp(timestamp);
72 72
73 73 send_phase_events(time_partitions);
74 74 send_garbage_collection_event();
75 75 }
76 76
77 77 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
78 78 assert_set_gc_id();
79 79
80 80 report_gc_end_impl(timestamp, time_partitions);
81 81
82 82 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
83 83 }
↓ open down ↓ |
83 lines elided |
↑ open up ↑ |
84 84
85 85 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
86 86 assert_set_gc_id();
87 87
88 88 send_reference_stats_event(REF_SOFT, rps.soft_count());
89 89 send_reference_stats_event(REF_WEAK, rps.weak_count());
90 90 send_reference_stats_event(REF_FINAL, rps.final_count());
91 91 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
92 92 }
93 93
94 -class ObjectCountEventSenderClosure : public KlassInfoClosure {
95 - GCTracer* _gc_tracer;
96 - public:
97 - ObjectCountEventSenderClosure(GCTracer* gc_tracer) : _gc_tracer(gc_tracer) {}
98 - private:
99 - void do_cinfo(KlassInfoEntry* entry) {
100 - if (is_visible_klass(entry->klass())) {
101 - _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
102 - entry->words() * BytesPerWord);
103 - }
94 +void ObjectCountEventSenderClosure::do_cinfo(KlassInfoEntry* entry) {
95 + if (should_send_event(entry)) {
96 + send_event(entry);
104 97 }
98 +}
105 99
100 +void ObjectCountEventSenderClosure::send_event(KlassInfoEntry* entry) {
101 + _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
102 + entry->words() * BytesPerWord);
103 +}
104 +
105 +bool ObjectCountEventSenderClosure::should_send_event(KlassInfoEntry* entry) const {
106 + double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
107 + return percentage_of_heap > _size_threshold_percentage;
108 +}
109 +
110 +bool ObjectCountFilter::do_object_b(oop obj) {
111 + bool is_alive = _is_alive == NULL? true : _is_alive->do_object_b(obj);
112 + return is_alive && is_externally_visible_klass(obj->klass());
113 +}
114 +
115 +bool ObjectCountFilter::is_externally_visible_klass(klassOop k) const {
106 116 // Do not expose internal implementation specific classes
107 - bool is_visible_klass(klassOop k) {
108 - return k->klass_part()->oop_is_instance() ||
109 - (k->klass_part()->oop_is_array() && k != Universe::systemObjArrayKlassObj());
110 - }
111 -};
117 + return (k->klass_part()->oop_is_instance() || k->klass_part()->oop_is_array()) &&
118 + k != Universe::systemObjArrayKlassObj();
119 +}
112 120
113 121 void GCTracer::report_object_count_after_gc(BoolObjectClosure *is_alive_cl) {
114 122 if (should_send_object_count_after_gc_event()) {
115 123 ResourceMark rm;
116 124
117 125 KlassInfoTable cit(HeapInspection::start_of_perm_gen());
118 126 if (!cit.allocation_failed()) {
119 - ObjectCountEventSenderClosure event_sender(this);
120 - HeapInspection::instance_inspection(&cit, &event_sender, false, is_alive_cl);
127 + ObjectCountFilter object_filter(is_alive_cl);
128 + HeapInspection::populate_table(&cit, false, &object_filter);
129 +
130 + ObjectCountEventSenderClosure event_sender(this, cit.size_of_instances_in_words());
131 + cit.iterate(&event_sender);
121 132 }
122 133 }
123 134 }
124 135
125 136 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const {
126 137 assert_set_gc_id();
127 138
128 139 send_gc_heap_summary_event(when, heap_summary);
129 140 send_perm_gen_summary_event(when, perm_gen_summary);
130 141 }
131 142
132 143 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
133 144 assert_set_gc_id();
134 145 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
135 146
136 147 GCTracer::report_gc_end_impl(timestamp, time_partitions);
137 148 send_young_gc_event();
138 149
139 150 _tenuring_threshold = UNSET_TENURING_THRESHOLD;
140 151 }
141 152
142 153 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
143 154 assert_set_gc_id();
144 155
145 156 send_promotion_failed_event(pf_info);
146 157 }
147 158
148 159 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
149 160 _tenuring_threshold = tenuring_threshold;
150 161 }
151 162
152 163 void OldGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
153 164 assert_set_gc_id();
154 165
155 166 GCTracer::report_gc_end_impl(timestamp, time_partitions);
156 167 send_old_gc_event();
157 168 }
158 169
159 170 void ParallelOldTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
160 171 assert_set_gc_id();
161 172
162 173 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
163 174 send_parallel_old_event();
164 175 }
165 176
166 177 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
167 178 assert_set_gc_id();
168 179
169 180 _parallel_old_gc_info.report_dense_prefix(dense_prefix);
170 181 }
171 182
172 183 void OldGCTracer::report_concurrent_mode_failure() {
173 184 assert_set_gc_id();
174 185
175 186 send_concurrent_mode_failure_event();
176 187 }
177 188
178 189 #ifndef SERIALGC
179 190 void G1NewTracer::report_yc_type(G1YCType type) {
180 191 assert_set_gc_id();
181 192
182 193 _g1_young_gc_info.set_type(type);
183 194 }
184 195
185 196 void G1NewTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
186 197 assert_set_gc_id();
187 198
188 199 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
189 200 send_g1_young_gc_event();
190 201 }
191 202
192 203 void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {
193 204 assert_set_gc_id();
194 205
195 206 send_evacuation_info_event(info);
196 207 }
197 208
198 209 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {
199 210 assert_set_gc_id();
200 211
201 212 send_evacuation_failed_event(ef_info);
202 213 ef_info.reset();
203 214 }
204 215 #endif
↓ open down ↓ |
74 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX