Path: blob/master/test/hotspot/jtreg/gc/epsilon/TestManyThreads.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 TestManyThreads27* @requires vm.gc.Epsilon28* @summary Test allocations from many threads29*30* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k31* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC32* gc.epsilon.TestManyThreads33*34* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k35* -Xint36* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC37* gc.epsilon.TestManyThreads38*39* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k40* -Xbatch -Xcomp -XX:TieredStopAtLevel=141* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC42* gc.epsilon.TestManyThreads43*44* @run main/othervm -XX:-UseTLAB -Xmx256m -Xss512k45* -Xbatch -Xcomp -XX:-TieredCompilation46* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC47* gc.epsilon.TestManyThreads48*49* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k50* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC51* gc.epsilon.TestManyThreads52*53* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k54* -Xint55* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC56* gc.epsilon.TestManyThreads57*58* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k59* -Xbatch -Xcomp -XX:TieredStopAtLevel=160* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC61* gc.epsilon.TestManyThreads62*63* @run main/othervm -XX:+UseTLAB -Xmx256m -Xss512k64* -Xbatch -Xcomp -XX:-TieredCompilation65* -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC66* gc.epsilon.TestManyThreads67*/6869import java.util.concurrent.atomic.*;7071public class TestManyThreads {7273static int COUNT = Integer.getInteger("count", 128); // 128 * 4M max tlabs = 512M, would overflow without TLAB sizing7475static volatile Object sink;76static volatile Throwable failed;77static final AtomicInteger allocated = new AtomicInteger();7879public static void workload() {80try {81sink = new Object();82allocated.incrementAndGet();83Thread.sleep(3600 * 1000);84} catch (Throwable e) {85failed = e;86}87}8889public static void main(String[] args) throws Throwable {90for (int c = 0; c < COUNT; c++) {91Thread t = new Thread(TestManyThreads::workload);92t.setDaemon(true);93t.start();94}9596while ((failed == null) && (allocated.get() != COUNT)) {97Thread.sleep(100);98}99100if (failed != null) {101throw failed;102}103}104105}106107108