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  *
  28  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  29  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  30  *      -XX:+ShenandoahDegeneratedGC
  31  *      -Dtarget=10000
  32  *      TestLotsOfCycles
  33  *
  34  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  35  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
  36  *      -XX:-ShenandoahDegeneratedGC
  37  *      -Dtarget=10000
  38  *      TestLotsOfCycles
  39  */
  40 
  41 /*
  42  * @test TestLotsOfCycles
  43  * @key gc
  44  *
  45  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  46  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  47  *      -XX:+ShenandoahOOMDuringEvacALot
  48  *      -Dtarget=1000
  49  *      TestLotsOfCycles
  50  *
  51  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  52  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  53  *      -XX:+ShenandoahAllocFailureALot
  54  *      -Dtarget=1000
  55  *      TestLotsOfCycles
  56  *
  57  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  58  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
  59  *      -Dtarget=1000
  60  *      TestLotsOfCycles
  61  */
  62 
  63 /*
  64  * @test TestLotsOfCycles
  65  * @key gc
  66  *
  67  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  68  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
  69  *      -Dtarget=10000
  70  *      TestLotsOfCycles
  71  */
  72 
  73 /*
  74  * @test TestLotsOfCycles
  75  * @key gc
  76  *
  77  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  78  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
  79  *      -Dtarget=10000
  80  *      TestLotsOfCycles
  81  */
  82 
  83 /*
  84  * @test TestLotsOfCycles
  85  * @key gc
  86  *
  87  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  88  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
  89  *      -Dtarget=1000
  90  *     TestLotsOfCycles
  91  */
  92 
  93 /*
  94  * @test TestLotsOfCycles
  95  * @key gc
  96  *
  97  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
  98  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
  99  *      -XX:+ShenandoahOOMDuringEvacALot
 100  *      -Dtarget=1000
 101  *      TestLotsOfCycles
 102  *
 103  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 104  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 105  *      -XX:+ShenandoahAllocFailureALot
 106  *      -Dtarget=1000
 107  *      TestLotsOfCycles
 108  *
 109  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 110  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
 111  *      -Dtarget=1000
 112  *      TestLotsOfCycles
 113  */
 114 
 115 /*
 116  * @test TestLotsOfCycles
 117  * @key gc
 118  *
 119  * @run main/othervm/timeout=480 -Xmx16m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 120  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
 121  *      -Dtarget=10000
 122  *      TestLotsOfCycles
 123  */
 124 
 125 public class TestLotsOfCycles {
 126 
 127     static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation, around 1K cycles to handle
 128     static final long STRIDE = 100_000;
 129 
 130     static volatile Object sink;
 131 
 132     public static void main(String[] args) throws Exception {
 133         long count = TARGET_MB * 1024 * 1024 / 16;
 134         for (long c = 0; c < count; c += STRIDE) {
 135             for (long s = 0; s < STRIDE; s++) {
 136                 sink = new Object();
 137             }
 138             Thread.sleep(1);
 139         }
 140     }
 141 
 142 }