1 /*
2 * Copyright (c) 2013, 2015, Red Hat, Inc. and/or its affiliates.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
118 }
119
120 void ShenandoahMetricsSnapshot::snap_before() {
121 _used_before = _heap->used();
122 _if_before = ShenandoahMetrics::internal_fragmentation();
123 _ef_before = ShenandoahMetrics::external_fragmentation();
124 }
125 void ShenandoahMetricsSnapshot::snap_after() {
126 _used_after = _heap->used();
127 _if_after = ShenandoahMetrics::internal_fragmentation();
128 _ef_after = ShenandoahMetrics::external_fragmentation();
129 }
130
131 void ShenandoahMetricsSnapshot::print() {
132 log_info(gc, ergo)("Used: before: " SIZE_FORMAT "M, after: " SIZE_FORMAT "M", _used_before/M, _used_after/M);
133 log_info(gc, ergo)("Internal frag: before: %.1f%%, after: %.1f%%", _if_before * 100, _if_after * 100);
134 log_info(gc, ergo)("External frag: before: %.1f%%, after: %.1f%%", _ef_before * 100, _ef_after * 100);
135 }
136
137 bool ShenandoahMetricsSnapshot::is_good_progress(const char *label) {
138
139 // Under the critical threshold? Declare failure.
140 size_t free_actual = _heap->free_set()->available();
141 size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold;
142 if (free_actual < free_expected) {
143 log_info(gc, ergo)("Not enough free space (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
144 free_actual / M, free_expected / M, label);
145 return false;
146 }
147
148 // Freed up enough? Good! Declare victory.
149 size_t progress_actual = (_used_before > _used_after) ? _used_before - _used_after : 0;
150 size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
151 if (progress_actual >= progress_expected) {
152 return true;
153 }
154 log_info(gc,ergo)("Not enough progress (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
155 progress_actual / M, progress_expected / M, label);
156
157 // Internal fragmentation is down? Good! Declare victory.
158 double if_actual = _if_before - _if_after;
159 double if_expected = 0.01; // 1% should be enough
160 if (if_actual > if_expected) {
161 return true;
162 }
163 log_info(gc,ergo)("Not enough internal fragmentation improvement (%.1f%%, need %.1f%%) after %s",
164 if_actual * 100, if_expected * 100, label);
165
166 // External fragmentation is down? Good! Declare victory.
167 double ef_actual = _ef_before - _ef_after;
168 double ef_expected = 0.01; // 1% should be enough
169 if (ef_actual > ef_expected) {
170 return true;
171 }
172 log_info(gc,ergo)("Not enough external fragmentation improvement (%.1f%%, need %.1f%%) after %s",
173 if_actual * 100, if_expected * 100, label);
174
175 // Nothing good had happened.
176 return false;
177 }
178
|
1 /*
2 * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
118 }
119
120 void ShenandoahMetricsSnapshot::snap_before() {
121 _used_before = _heap->used();
122 _if_before = ShenandoahMetrics::internal_fragmentation();
123 _ef_before = ShenandoahMetrics::external_fragmentation();
124 }
125 void ShenandoahMetricsSnapshot::snap_after() {
126 _used_after = _heap->used();
127 _if_after = ShenandoahMetrics::internal_fragmentation();
128 _ef_after = ShenandoahMetrics::external_fragmentation();
129 }
130
131 void ShenandoahMetricsSnapshot::print() {
132 log_info(gc, ergo)("Used: before: " SIZE_FORMAT "M, after: " SIZE_FORMAT "M", _used_before/M, _used_after/M);
133 log_info(gc, ergo)("Internal frag: before: %.1f%%, after: %.1f%%", _if_before * 100, _if_after * 100);
134 log_info(gc, ergo)("External frag: before: %.1f%%, after: %.1f%%", _ef_before * 100, _ef_after * 100);
135 }
136
137 bool ShenandoahMetricsSnapshot::is_good_progress(const char *label) {
138 // Under the critical threshold? Declare failure.
139 size_t free_actual = _heap->free_set()->available();
140 size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold;
141 if (free_actual < free_expected) {
142 log_info(gc, ergo)("Not enough free space (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
143 free_actual / M, free_expected / M, label);
144 return false;
145 }
146
147 // Freed up enough? Good! Declare victory.
148 size_t progress_actual = (_used_before > _used_after) ? _used_before - _used_after : 0;
149 size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
150 if (progress_actual >= progress_expected) {
151 return true;
152 }
153 log_info(gc,ergo)("Not enough progress (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
154 progress_actual / M, progress_expected / M, label);
155
156 // Internal fragmentation is down? Good! Declare victory.
157 double if_actual = _if_before - _if_after;
158 double if_expected = 0.01; // 1% should be enough
159 if (if_actual > if_expected) {
160 return true;
161 }
162 log_info(gc,ergo)("Not enough internal fragmentation improvement (%.1f%%, need %.1f%%) after %s",
163 if_actual * 100, if_expected * 100, label);
164
165 // External fragmentation is down? Good! Declare victory.
166 double ef_actual = _ef_before - _ef_after;
167 double ef_expected = 0.01; // 1% should be enough
168 if (ef_actual > ef_expected) {
169 return true;
170 }
171 log_info(gc,ergo)("Not enough external fragmentation improvement (%.1f%%, need %.1f%%) after %s",
172 if_actual * 100, if_expected * 100, label);
173
174 // Nothing good had happened.
175 return false;
176 }
|