|
1 /* |
|
2 * Copyright (c) 2019, 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" |
|
26 #include "gc/g1/g1EvacuationInfo.hpp" |
|
27 #include "gc/g1/g1Trace.hpp" |
|
28 #include "gc/g1/g1YCTypes.hpp" |
|
29 #include "gc/shared/gcHeapSummary.hpp" |
|
30 #include "jfr/jfrEvents.hpp" |
|
31 |
|
32 void G1NewTracer::report_yc_type(G1YCType type) { |
|
33 _g1_young_gc_info.set_type(type); |
|
34 } |
|
35 |
|
36 void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { |
|
37 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions); |
|
38 send_g1_young_gc_event(); |
|
39 } |
|
40 |
|
41 void G1NewTracer::report_evacuation_info(G1EvacuationInfo* info) { |
|
42 send_evacuation_info_event(info); |
|
43 } |
|
44 |
|
45 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) { |
|
46 send_evacuation_failed_event(ef_info); |
|
47 ef_info.reset(); |
|
48 } |
|
49 |
|
50 void G1NewTracer::report_evacuation_statistics(const G1EvacSummary& young_summary, const G1EvacSummary& old_summary) const { |
|
51 send_young_evacuation_statistics(young_summary); |
|
52 send_old_evacuation_statistics(old_summary); |
|
53 } |
|
54 |
|
55 void G1NewTracer::report_basic_ihop_statistics(size_t threshold, |
|
56 size_t target_ccupancy, |
|
57 size_t current_occupancy, |
|
58 size_t last_allocation_size, |
|
59 double last_allocation_duration, |
|
60 double last_marking_length) { |
|
61 send_basic_ihop_statistics(threshold, |
|
62 target_ccupancy, |
|
63 current_occupancy, |
|
64 last_allocation_size, |
|
65 last_allocation_duration, |
|
66 last_marking_length); |
|
67 } |
|
68 |
|
69 void G1NewTracer::report_adaptive_ihop_statistics(size_t threshold, |
|
70 size_t internal_target_occupancy, |
|
71 size_t current_occupancy, |
|
72 size_t additional_buffer_size, |
|
73 double predicted_allocation_rate, |
|
74 double predicted_marking_length, |
|
75 bool prediction_active) { |
|
76 send_adaptive_ihop_statistics(threshold, |
|
77 internal_target_occupancy, |
|
78 additional_buffer_size, |
|
79 current_occupancy, |
|
80 predicted_allocation_rate, |
|
81 predicted_marking_length, |
|
82 prediction_active); |
|
83 } |
|
84 |
|
85 void G1NewTracer::send_g1_young_gc_event() { |
|
86 EventG1GarbageCollection e(UNTIMED); |
|
87 if (e.should_commit()) { |
|
88 e.set_gcId(GCId::current()); |
|
89 e.set_type(_g1_young_gc_info.type()); |
|
90 e.set_starttime(_shared_gc_info.start_timestamp()); |
|
91 e.set_endtime(_shared_gc_info.end_timestamp()); |
|
92 e.commit(); |
|
93 } |
|
94 } |
|
95 |
|
96 void G1NewTracer::send_evacuation_info_event(G1EvacuationInfo* info) { |
|
97 EventEvacuationInformation e; |
|
98 if (e.should_commit()) { |
|
99 e.set_gcId(GCId::current()); |
|
100 e.set_cSetRegions(info->collectionset_regions()); |
|
101 e.set_cSetUsedBefore(info->collectionset_used_before()); |
|
102 e.set_cSetUsedAfter(info->collectionset_used_after()); |
|
103 e.set_allocationRegions(info->allocation_regions()); |
|
104 e.set_allocationRegionsUsedBefore(info->alloc_regions_used_before()); |
|
105 e.set_allocationRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied()); |
|
106 e.set_bytesCopied(info->bytes_copied()); |
|
107 e.set_regionsFreed(info->regions_freed()); |
|
108 e.commit(); |
|
109 } |
|
110 } |
|
111 |
|
112 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const { |
|
113 EventEvacuationFailed e; |
|
114 if (e.should_commit()) { |
|
115 // Create JFR structured failure data |
|
116 JfrStructCopyFailed evac_failed; |
|
117 evac_failed.set_objectCount(ef_info.failed_count()); |
|
118 evac_failed.set_firstSize(ef_info.first_size()); |
|
119 evac_failed.set_smallestSize(ef_info.smallest_size()); |
|
120 evac_failed.set_totalSize(ef_info.total_size()); |
|
121 // Add to the event |
|
122 e.set_gcId(GCId::current()); |
|
123 e.set_evacuationFailed(evac_failed); |
|
124 e.commit(); |
|
125 } |
|
126 } |
|
127 |
|
128 static JfrStructG1EvacuationStatistics |
|
129 create_g1_evacstats(unsigned gcid, const G1EvacSummary& summary) { |
|
130 JfrStructG1EvacuationStatistics s; |
|
131 s.set_gcId(gcid); |
|
132 s.set_allocated(summary.allocated() * HeapWordSize); |
|
133 s.set_wasted(summary.wasted() * HeapWordSize); |
|
134 s.set_used(summary.used() * HeapWordSize); |
|
135 s.set_undoWaste(summary.undo_wasted() * HeapWordSize); |
|
136 s.set_regionEndWaste(summary.region_end_waste() * HeapWordSize); |
|
137 s.set_regionsRefilled(summary.regions_filled()); |
|
138 s.set_directAllocated(summary.direct_allocated() * HeapWordSize); |
|
139 s.set_failureUsed(summary.failure_used() * HeapWordSize); |
|
140 s.set_failureWaste(summary.failure_waste() * HeapWordSize); |
|
141 return s; |
|
142 } |
|
143 |
|
144 void G1NewTracer::send_young_evacuation_statistics(const G1EvacSummary& summary) const { |
|
145 EventG1EvacuationYoungStatistics surv_evt; |
|
146 if (surv_evt.should_commit()) { |
|
147 surv_evt.set_statistics(create_g1_evacstats(GCId::current(), summary)); |
|
148 surv_evt.commit(); |
|
149 } |
|
150 } |
|
151 |
|
152 void G1NewTracer::send_old_evacuation_statistics(const G1EvacSummary& summary) const { |
|
153 EventG1EvacuationOldStatistics old_evt; |
|
154 if (old_evt.should_commit()) { |
|
155 old_evt.set_statistics(create_g1_evacstats(GCId::current(), summary)); |
|
156 old_evt.commit(); |
|
157 } |
|
158 } |
|
159 |
|
160 void G1NewTracer::send_basic_ihop_statistics(size_t threshold, |
|
161 size_t target_occupancy, |
|
162 size_t current_occupancy, |
|
163 size_t last_allocation_size, |
|
164 double last_allocation_duration, |
|
165 double last_marking_length) { |
|
166 EventG1BasicIHOP evt; |
|
167 if (evt.should_commit()) { |
|
168 evt.set_gcId(GCId::current()); |
|
169 evt.set_threshold(threshold); |
|
170 evt.set_targetOccupancy(target_occupancy); |
|
171 evt.set_thresholdPercentage(target_occupancy > 0 ? ((double)threshold / target_occupancy) : 0.0); |
|
172 evt.set_currentOccupancy(current_occupancy); |
|
173 evt.set_recentMutatorAllocationSize(last_allocation_size); |
|
174 evt.set_recentMutatorDuration(last_allocation_duration * MILLIUNITS); |
|
175 evt.set_recentAllocationRate(last_allocation_duration != 0.0 ? last_allocation_size / last_allocation_duration : 0.0); |
|
176 evt.set_lastMarkingDuration(last_marking_length * MILLIUNITS); |
|
177 evt.commit(); |
|
178 } |
|
179 } |
|
180 |
|
181 void G1NewTracer::send_adaptive_ihop_statistics(size_t threshold, |
|
182 size_t internal_target_occupancy, |
|
183 size_t current_occupancy, |
|
184 size_t additional_buffer_size, |
|
185 double predicted_allocation_rate, |
|
186 double predicted_marking_length, |
|
187 bool prediction_active) { |
|
188 EventG1AdaptiveIHOP evt; |
|
189 if (evt.should_commit()) { |
|
190 evt.set_gcId(GCId::current()); |
|
191 evt.set_threshold(threshold); |
|
192 evt.set_thresholdPercentage(internal_target_occupancy > 0 ? ((double)threshold / internal_target_occupancy) : 0.0); |
|
193 evt.set_ihopTargetOccupancy(internal_target_occupancy); |
|
194 evt.set_currentOccupancy(current_occupancy); |
|
195 evt.set_additionalBufferSize(additional_buffer_size); |
|
196 evt.set_predictedAllocationRate(predicted_allocation_rate); |
|
197 evt.set_predictedMarkingDuration(predicted_marking_length * MILLIUNITS); |
|
198 evt.set_predictionActive(prediction_active); |
|
199 evt.commit(); |
|
200 } |
|
201 } |
|
202 |
|
203 void G1OldTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) { |
|
204 _shared_gc_info.set_start_timestamp(timestamp); |
|
205 } |
|
206 |
|
207 void G1OldTracer::set_gc_cause(GCCause::Cause cause) { |
|
208 _shared_gc_info.set_cause(cause); |
|
209 } |
|
210 |
|
211 void G1MMUTracer::report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec) { |
|
212 send_g1_mmu_event(time_slice_sec * MILLIUNITS, |
|
213 gc_time_sec * MILLIUNITS, |
|
214 max_time_sec * MILLIUNITS); |
|
215 } |
|
216 |
|
217 void G1MMUTracer::send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms) { |
|
218 EventG1MMU e; |
|
219 if (e.should_commit()) { |
|
220 e.set_gcId(GCId::current()); |
|
221 e.set_timeSlice(time_slice_ms); |
|
222 e.set_gcTime(gc_time_ms); |
|
223 e.set_pauseTarget(max_time_ms); |
|
224 e.commit(); |
|
225 } |
|
226 } |