1 /* 2 * Copyright (c) 2020, Red Hat, Inc. 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 /* 26 * @test id=passive 27 * @key randomness 28 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 29 * @requires vm.gc.Shenandoah 30 * @library /test/lib 31 * 32 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 33 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 34 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 35 * -XX:+ShenandoahVerify 36 * -XX:+ResizeTLAB 37 * TestResizeTLAB 38 * 39 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 40 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 41 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 42 * -XX:+ShenandoahVerify 43 * -XX:-ResizeTLAB 44 * TestResizeTLAB 45 * 46 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 47 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 48 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 49 * -XX:+ShenandoahVerify 50 * -XX:+ResizeTLAB 51 * TestResizeTLAB 52 * 53 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 54 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 55 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 56 * -XX:+ShenandoahVerify 57 * -XX:-ResizeTLAB 58 * TestResizeTLAB 59 */ 60 61 /* 62 * @test id=aggressive 63 * @key randomness 64 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 65 * @requires vm.gc.Shenandoah 66 * @library /test/lib 67 * 68 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 69 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 70 * -XX:+ShenandoahVerify 71 * -XX:+ResizeTLAB 72 * TestResizeTLAB 73 * 74 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 75 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 76 * -XX:+ShenandoahVerify 77 * -XX:-ResizeTLAB 78 * TestResizeTLAB 79 */ 80 81 /* 82 * @test id=adaptive 83 * @key randomness 84 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 85 * @requires vm.gc.Shenandoah 86 * @library /test/lib 87 * 88 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 89 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 90 * -XX:+ShenandoahVerify 91 * -XX:+ResizeTLAB 92 * TestResizeTLAB 93 * 94 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 95 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 96 * -XX:+ShenandoahVerify 97 * -XX:-ResizeTLAB 98 * TestResizeTLAB 99 */ 100 101 /* 102 * @test id=static 103 * @key randomness 104 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 105 * @requires vm.gc.Shenandoah 106 * @library /test/lib 107 * 108 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 109 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 110 * -XX:+ShenandoahVerify 111 * -XX:+ResizeTLAB 112 * TestResizeTLAB 113 * 114 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 115 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 116 * -XX:+ShenandoahVerify 117 * -XX:-ResizeTLAB 118 * TestResizeTLAB 119 */ 120 121 /* 122 * @test id=compact 123 * @key randomness 124 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 125 * @requires vm.gc.Shenandoah 126 * @library /test/lib 127 * 128 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 129 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 130 * -XX:+ShenandoahVerify 131 * -XX:+ResizeTLAB 132 * TestResizeTLAB 133 * 134 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 135 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 136 * -XX:+ShenandoahVerify 137 * -XX:-ResizeTLAB 138 * TestResizeTLAB 139 */ 140 141 import java.util.Random; 142 import jdk.test.lib.Utils; 143 144 public class TestResizeTLAB { 145 146 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation 147 148 static volatile Object sink; 149 150 public static void main(String[] args) throws Exception { 151 final int min = 0; 152 final int max = 384 * 1024; 153 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2)); 154 155 Random r = Utils.getRandomInstance(); 156 for (long c = 0; c < count; c++) { 157 sink = new int[min + r.nextInt(max - min)]; 158 } 159 } 160 161 }