< prev index next >

test/gc/g1/TestRemsetLoggingTools.java

Print this page
rev 9738 : [mq]: 8145534-testremsetlogging-takes-too-long


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * Common helpers for TestRemsetLogging* tests
  26  */
  27 
  28 import com.sun.management.HotSpotDiagnosticMXBean;
  29 import com.sun.management.VMOption;

  30 
  31 import jdk.test.lib.*;
  32 import java.lang.management.ManagementFactory;
  33 import java.util.ArrayList;
  34 import java.util.Arrays;
  35 
  36 class VerifySummaryOutput {
  37     // 4M size, both are directly allocated into the old gen
  38     static Object[] largeObject1 = new Object[1024 * 1024];
  39     static Object[] largeObject2 = new Object[1024 * 1024];
  40 
  41     static int[] temp;
  42 
  43     public static void main(String[] args) {
  44         // create some cross-references between these objects
  45         for (int i = 0; i < largeObject1.length; i++) {
  46             largeObject1[i] = largeObject2;
  47         }
  48 
  49         for (int i = 0; i < largeObject2.length; i++) {
  50             largeObject2[i] = largeObject1;
  51         }
  52 
  53         int numGCs = Integer.parseInt(args[0]);
  54 
  55         if (numGCs > 0) {
  56             // try to force a minor collection: the young gen is 4M, the
  57             // amount of data allocated below is roughly that (4*1024*1024 +
  58             // some header data)
  59             for (int i = 0; i < 1024 ; i++) {
  60                 temp = new int[1024];
  61             }
  62         }
  63 
  64         for (int i = 0; i < numGCs - 1; i++) {
  65             System.gc();



  66         }
  67     }
  68 }
  69 
  70 public class TestRemsetLoggingTools {
  71 
  72     // the VM is currently run using G1GC, i.e. trying to test G1 functionality.
  73     public static boolean testingG1GC() {
  74         HotSpotDiagnosticMXBean diagnostic =
  75             ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
  76 
  77         VMOption option = diagnostic.getVMOption("UseG1GC");
  78         if (option.getValue().equals("false")) {
  79           System.out.println("Skipping this test. It is only a G1 test.");
  80           return false;
  81         }
  82         return true;
  83     }
  84 
  85     public static String runTest(String[] additionalArgs, int numGCs) throws Exception {
  86         ArrayList<String> finalargs = new ArrayList<String>();
  87         String[] defaultArgs = new String[] {



  88             "-XX:+UseG1GC",
  89             "-Xmn4m",

  90             "-Xms20m",
  91             "-Xmx20m",

  92             "-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking
  93             "-XX:+UnlockDiagnosticVMOptions",
  94             "-XX:G1HeapRegionSize=1M",
  95         };
  96 
  97         finalargs.addAll(Arrays.asList(defaultArgs));
  98 
  99         if (additionalArgs != null) {
 100             finalargs.addAll(Arrays.asList(additionalArgs));
 101         }
 102 
 103         finalargs.add(VerifySummaryOutput.class.getName());
 104         finalargs.add(String.valueOf(numGCs));
 105 
 106         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 107             finalargs.toArray(new String[0]));
 108         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 109 
 110         output.shouldHaveExitValue(0);
 111 




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * Common helpers for TestRemsetLogging* tests
  26  */
  27 
  28 import com.sun.management.HotSpotDiagnosticMXBean;
  29 import com.sun.management.VMOption;
  30 import sun.hotspot.WhiteBox;
  31 
  32 import jdk.test.lib.*;
  33 import java.lang.management.ManagementFactory;
  34 import java.util.ArrayList;
  35 import java.util.Arrays;
  36 
  37 class VerifySummaryOutput {






  38     public static void main(String[] args) {









  39         int numGCs = Integer.parseInt(args[0]);
  40 
  41         // Perform the requested amount of GCs.
  42         WhiteBox wb = WhiteBox.getWhiteBox();







  43         for (int i = 0; i < numGCs - 1; i++) {
  44             wb.youngGC();
  45         }
  46         if (numGCs > 0) {
  47           wb.fullGC();
  48         }
  49     }
  50 }
  51 
  52 public class TestRemsetLoggingTools {
  53 













  54     public static String runTest(String[] additionalArgs, int numGCs) throws Exception {
  55         ArrayList<String> finalargs = new ArrayList<String>();
  56         String[] defaultArgs = new String[] {
  57             "-Xbootclasspath/a:.",
  58             "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
  59             "-cp", System.getProperty("java.class.path"),
  60             "-XX:+UseG1GC",
  61             "-Xmn4m",
  62             "-Xint", // -Xint makes the test run faster
  63             "-Xms20m",
  64             "-Xmx20m",
  65             "-XX:ParallelGCThreads=1",
  66             "-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking
  67             "-XX:+UnlockDiagnosticVMOptions",
  68             "-XX:G1HeapRegionSize=1M",
  69         };
  70 
  71         finalargs.addAll(Arrays.asList(defaultArgs));
  72 
  73         if (additionalArgs != null) {
  74             finalargs.addAll(Arrays.asList(additionalArgs));
  75         }
  76 
  77         finalargs.add(VerifySummaryOutput.class.getName());
  78         finalargs.add(String.valueOf(numGCs));
  79 
  80         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  81             finalargs.toArray(new String[0]));
  82         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  83 
  84         output.shouldHaveExitValue(0);
  85 


< prev index next >