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 * @test TestPLABResize
26 * @bug 8141278
27 * @summary Test for PLAB resizing
28 * @requires vm.gc=="G1" | vm.gc=="null"
29 * @requires vm.opt.FlightRecorder != true
30 * @library /testlibrary /../../test/lib /
31 * @modules java.management
32 * @build ClassFileInstaller
33 * sun.hotspot.WhiteBox
34 * gc.g1.plab.lib.LogParser
35 * gc.g1.plab.lib.MemoryConsumer
36 * gc.g1.plab.lib.PLABUtils
37 * gc.g1.plab.lib.AppPLABResize
38 * @ignore 8150183
39 * @run main ClassFileInstaller sun.hotspot.WhiteBox
40 * sun.hotspot.WhiteBox$WhiteBoxPermission
41 * @run main gc.g1.plab.TestPLABResize
42 */
43 package gc.g1.plab;
44
45 import java.util.ArrayList;
46 import java.util.Arrays;
100 checkResults(out.getOutput(), testCase);
101 }
102 }
103
104 /**
105 * Checks testing results.
106 * Expected results - desired PLAB size is decreased and increased during promotion to Survivor.
107 *
108 * @param output - VM output
109 * @param testCase
110 */
111 private static void checkResults(String output, TestCase testCase) {
112 final LogParser log = new LogParser(output);
113 final Map<Long, Map<LogParser.ReportType, Map<String, Long>>> entries = log.getEntries();
114
115 final ArrayList<Long> plabSizes = entries.entrySet()
116 .stream()
117 .map(item -> {
118 return item.getValue()
119 .get(LogParser.ReportType.SURVIVOR_STATS)
120 .get("desired_plab_sz");
121 })
122 .collect(Collectors.toCollection(ArrayList::new));
123
124 // Check that desired plab size was changed during iterations.
125 // It should decrease during first half of iterations
126 // and increase after.
127 List<Long> decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2);
128 List<Long> increasedPlabs = plabSizes.subList(testCase.getIterations() * 2, testCase.getIterations() * 3);
129
130 Long prev = decreasedPlabs.get(0);
131 for (int index = 1; index < decreasedPlabs.size(); ++index) {
132 Long current = decreasedPlabs.get(index);
133 if (prev < current) {
134 System.out.println(output);
135 throw new RuntimeException("Test failed! Expect that previous PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current);
136 }
137 prev = current;
138 }
139
140 prev = increasedPlabs.get(0);
|
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 * @test TestPLABResize
26 * @bug 8141278 8141141
27 * @summary Test for PLAB resizing
28 * @requires vm.gc=="G1" | vm.gc=="null"
29 * @requires vm.opt.FlightRecorder != true
30 * @library /testlibrary /../../test/lib /
31 * @modules java.management
32 * @build ClassFileInstaller
33 * sun.hotspot.WhiteBox
34 * gc.g1.plab.lib.LogParser
35 * gc.g1.plab.lib.MemoryConsumer
36 * gc.g1.plab.lib.PLABUtils
37 * gc.g1.plab.lib.AppPLABResize
38 * @ignore 8150183
39 * @run main ClassFileInstaller sun.hotspot.WhiteBox
40 * sun.hotspot.WhiteBox$WhiteBoxPermission
41 * @run main gc.g1.plab.TestPLABResize
42 */
43 package gc.g1.plab;
44
45 import java.util.ArrayList;
46 import java.util.Arrays;
100 checkResults(out.getOutput(), testCase);
101 }
102 }
103
104 /**
105 * Checks testing results.
106 * Expected results - desired PLAB size is decreased and increased during promotion to Survivor.
107 *
108 * @param output - VM output
109 * @param testCase
110 */
111 private static void checkResults(String output, TestCase testCase) {
112 final LogParser log = new LogParser(output);
113 final Map<Long, Map<LogParser.ReportType, Map<String, Long>>> entries = log.getEntries();
114
115 final ArrayList<Long> plabSizes = entries.entrySet()
116 .stream()
117 .map(item -> {
118 return item.getValue()
119 .get(LogParser.ReportType.SURVIVOR_STATS)
120 .get("actual");
121 })
122 .collect(Collectors.toCollection(ArrayList::new));
123
124 // Check that desired plab size was changed during iterations.
125 // It should decrease during first half of iterations
126 // and increase after.
127 List<Long> decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2);
128 List<Long> increasedPlabs = plabSizes.subList(testCase.getIterations() * 2, testCase.getIterations() * 3);
129
130 Long prev = decreasedPlabs.get(0);
131 for (int index = 1; index < decreasedPlabs.size(); ++index) {
132 Long current = decreasedPlabs.get(index);
133 if (prev < current) {
134 System.out.println(output);
135 throw new RuntimeException("Test failed! Expect that previous PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current);
136 }
137 prev = current;
138 }
139
140 prev = increasedPlabs.get(0);
|