Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestElasticTLABDecay.java
40942 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.Epsilon & os.maxMemory > 1G29* @summary Epsilon is able to work with/without elastic TLABs30* @library /test/lib31*32* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:-EpsilonElasticTLABDecay gc.epsilon.TestElasticTLABDecay33* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:+EpsilonElasticTLABDecay -XX:EpsilonTLABDecayTime=1 gc.epsilon.TestElasticTLABDecay34* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:+EpsilonElasticTLAB -XX:+EpsilonElasticTLABDecay -XX:EpsilonTLABDecayTime=100 gc.epsilon.TestElasticTLABDecay35*/3637import java.util.Random;38import jdk.test.lib.Utils;3940public class TestElasticTLABDecay {41static int COUNT = Integer.getInteger("count", 3000); // ~500 MB allocation4243static byte[][] arr;4445public static void main(String[] args) throws Exception {46Random r = Utils.getRandomInstance();4748arr = new byte[COUNT * 100][];49for (int c = 0; c < COUNT; c++) {50arr[c] = new byte[c * 100];51for (int v = 0; v < c; v++) {52arr[c][v] = (byte)(r.nextInt(255) & 0xFF);53}54Thread.sleep(5);55}5657r = new Random(Utils.SEED);58for (int c = 0; c < COUNT; c++) {59byte[] b = arr[c];60if (b.length != (c * 100)) {61throw new IllegalStateException("Failure: length = " + b.length + ", need = " + (c*100));62}63for (int v = 0; v < c; v++) {64byte actual = b[v];65byte expected = (byte)(r.nextInt(255) & 0xFF);66if (actual != expected) {67throw new IllegalStateException("Failure: expected = " + expected + ", actual = " + actual);68}69}70}71}72}737475