Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestElasticTLABDecay.java
66644 views
/*1* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 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 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package gc.epsilon;2425/**26* @test TestElasticTLABDecay27* @key randomness28* @requires vm.gc.Epsilon29* @summary Epsilon is able to work with/without elastic TLABs decay30* @library /test/lib31*32* @run main/othervm -Xmx256m33* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC34* -XX:+EpsilonElasticTLAB -XX:-EpsilonElasticTLABDecay35* gc.epsilon.TestElasticTLABDecay36*37* @run main/othervm -Xmx256m38* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC39* -XX:+EpsilonElasticTLAB -XX:+EpsilonElasticTLABDecay -XX:EpsilonTLABDecayTime=140* gc.epsilon.TestElasticTLABDecay41*42* @run main/othervm -Xmx256m43* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC44* -XX:+EpsilonElasticTLAB -XX:+EpsilonElasticTLABDecay -XX:EpsilonTLABDecayTime=10045* gc.epsilon.TestElasticTLABDecay46*/4748import java.util.Random;49import jdk.test.lib.Utils;5051public class TestElasticTLABDecay {52static int COUNT = Integer.getInteger("count", 500); // ~100 MB allocation5354static byte[][] arr;5556public static void main(String[] args) throws Exception {57Random r = Utils.getRandomInstance();5859arr = new byte[COUNT * 100][];60for (int c = 0; c < COUNT; c++) {61arr[c] = new byte[c * 100];62for (int v = 0; v < c; v++) {63arr[c][v] = (byte)(r.nextInt(255) & 0xFF);64}65Thread.sleep(5);66}6768r = new Random(Utils.SEED);69for (int c = 0; c < COUNT; c++) {70byte[] b = arr[c];71if (b.length != (c * 100)) {72throw new IllegalStateException("Failure: length = " + b.length + ", need = " + (c*100));73}74for (int v = 0; v < c; v++) {75byte actual = b[v];76byte expected = (byte)(r.nextInt(255) & 0xFF);77if (actual != expected) {78throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);79}80}81}82}83}848586