1 /*
   2  * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 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 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 /*
  25  * @test TestLotsOfCycles
  26  * @key gc
  27  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  28  *
  29  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  30  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  31  *      -XX:+ShenandoahDegeneratedGC
  32  *      -Dtarget=10000
  33  *      TestLotsOfCycles
  34  *
  35  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  36  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  37  *      -XX:-ShenandoahDegeneratedGC
  38  *      -Dtarget=10000
  39  *      TestLotsOfCycles
  40  */
  41 
  42 /*
  43  * @test TestLotsOfCycles
  44  * @key gc
  45  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  46  *
  47  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  48  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  49  *      -XX:+ShenandoahOOMDuringEvacALot
  50  *      -Dtarget=1000
  51  *      TestLotsOfCycles
  52  *
  53  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  54  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  55  *      -XX:+ShenandoahAllocFailureALot
  56  *      -Dtarget=1000
  57  *      TestLotsOfCycles
  58  *
  59  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  60  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  61  *      -Dtarget=1000
  62  *      TestLotsOfCycles
  63  *
  64  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  65  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  66  *      -Dtarget=10000
  67  *      TestLotsOfCycles
  68  *
  69  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  70  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
  71  *      -Dtarget=10000
  72  *      TestLotsOfCycles
  73  *
  74  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  75  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
  76  *      -Dtarget=1000
  77  *     TestLotsOfCycles
  78  */
  79 
  80 /*
  81  * @test TestLotsOfCycles
  82  * @key gc
  83  * @requires vm.gc.Shenandoah & !vm.graal.enabled
  84  *
  85  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  86  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
  87  *      -XX:+ShenandoahOOMDuringEvacALot
  88  *      -Dtarget=1000
  89  *      TestLotsOfCycles
  90  *
  91  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  92  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
  93  *      -XX:+ShenandoahAllocFailureALot
  94  *      -Dtarget=1000
  95  *      TestLotsOfCycles
  96  *
  97  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  98  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal -XX:ShenandoahGCHeuristics=aggressive
  99  *      -Dtarget=1000
 100  *      TestLotsOfCycles
 101  *
 102  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 103  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=traversal
 104  *      -Dtarget=10000
 105  *      TestLotsOfCycles
 106  */
 107 
 108 public class TestLotsOfCycles {
 109 
 110     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation, around 1K cycles to handle
 111     static final long STRIDE = 100_000;
 112 
 113     static volatile Object sink;
 114 
 115     public static void main(String[] args) throws Exception {
 116         long count = TARGET_MB * 1024 * 1024 / 16;
 117         for (long c = 0; c < count; c += STRIDE) {
 118             for (long s = 0; s < STRIDE; s++) {
 119                 sink = new Object();
 120             }
 121             Thread.sleep(1);
 122         }
 123     }
 124 
 125 }