< prev index next >

test/gc/arguments/TestTargetSurvivorRatioFlag.java

Print this page




  62 
  63     // VM option values
  64     public static final long MAX_NEW_SIZE = 40 * M;
  65     public static final int SURVIVOR_RATIO = 8;
  66     public static final int MAX_TENURING_THRESHOLD = 15;
  67 
  68     // Value used to estimate amount of memory that should be allocated
  69     // and placed in survivor space.
  70     public static final double DELTA = 0.25;
  71 
  72     // Max variance of observed ratio
  73     public static double VARIANCE = 1;
  74 
  75     // Messages used by debuggee
  76     public static final String UNSUPPORTED_GC = "Unsupported GC";
  77     public static final String START_TEST = "Start test";
  78     public static final String END_TEST = "End test";
  79 
  80     // Patterns used during log parsing
  81     public static final String TENURING_DISTRIBUTION = "Desired survivor size";
  82     public static final String AGE_TABLE_ENTRY = "-[\\s]+age[\\s]+([0-9]+):[\\s]+([0-9]+)[\\s]+bytes,[\\s]+([0-9]+)[\\s]+total";
  83     public static final String MAX_SURVIVOR_SIZE = "Max survivor size: ([0-9]+)";
  84 
  85     public static void main(String args[]) throws Exception {
  86 
  87         LinkedList<String> options = new LinkedList<>(Arrays.asList(Utils.getTestJavaOpts()));
  88 
  89         // Need to consider the effect of TargetPLABWastePct=1 for G1 GC
  90         if (options.contains("-XX:+UseG1GC")) {
  91             VARIANCE = 2;
  92         } else {
  93             VARIANCE = 1;
  94         }
  95 
  96         negativeTest(-1, options);
  97         negativeTest(101, options);
  98 
  99         positiveTest(20, options);
 100         positiveTest(30, options);
 101         positiveTest(55, options);
 102         positiveTest(70, options);


 116         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
 117         OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
 118 
 119         analyzer.shouldHaveExitValue(1);
 120         analyzer.shouldContain("Error: Could not create the Java Virtual Machine.");
 121     }
 122 
 123     /**
 124      * Verify that actual survivor space usage ratio conforms specified TargetSurvivorRatio
 125      *
 126      * @param ratio value of TargetSurvivorRatio
 127      * @param options additional VM options
 128      */
 129     public static void positiveTest(int ratio, LinkedList<String> options) throws Exception {
 130         LinkedList<String> vmOptions = new LinkedList<>(options);
 131         Collections.addAll(vmOptions,
 132                 "-Xbootclasspath/a:.",
 133                 "-XX:+UnlockDiagnosticVMOptions",
 134                 "-XX:+WhiteBoxAPI",
 135                 "-XX:+UseAdaptiveSizePolicy",
 136                 "-XX:+PrintTenuringDistribution",
 137                 "-XX:MaxTenuringThreshold=" + MAX_TENURING_THRESHOLD,
 138                 "-XX:NewSize=" + MAX_NEW_SIZE,
 139                 "-XX:MaxNewSize=" + MAX_NEW_SIZE,
 140                 "-XX:InitialHeapSize=" + 2 * MAX_NEW_SIZE,
 141                 "-XX:MaxHeapSize=" + 2 * MAX_NEW_SIZE,
 142                 "-XX:SurvivorRatio=" + SURVIVOR_RATIO,
 143                 "-XX:TargetSurvivorRatio=" + ratio,
 144                 // For reducing variance of survivor size.
 145                 "-XX:TargetPLABWastePct=" + 1,
 146                 TargetSurvivorRatioVerifier.class.getName(),
 147                 Integer.toString(ratio)
 148         );
 149 
 150         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
 151         OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
 152 
 153         analyzer.shouldHaveExitValue(0);
 154 
 155         String output = analyzer.getOutput();
 156 




  62 
  63     // VM option values
  64     public static final long MAX_NEW_SIZE = 40 * M;
  65     public static final int SURVIVOR_RATIO = 8;
  66     public static final int MAX_TENURING_THRESHOLD = 15;
  67 
  68     // Value used to estimate amount of memory that should be allocated
  69     // and placed in survivor space.
  70     public static final double DELTA = 0.25;
  71 
  72     // Max variance of observed ratio
  73     public static double VARIANCE = 1;
  74 
  75     // Messages used by debuggee
  76     public static final String UNSUPPORTED_GC = "Unsupported GC";
  77     public static final String START_TEST = "Start test";
  78     public static final String END_TEST = "End test";
  79 
  80     // Patterns used during log parsing
  81     public static final String TENURING_DISTRIBUTION = "Desired survivor size";
  82     public static final String AGE_TABLE_ENTRY = ".*-[\\s]+age[\\s]+([0-9]+):[\\s]+([0-9]+)[\\s]+bytes,[\\s]+([0-9]+)[\\s]+total";
  83     public static final String MAX_SURVIVOR_SIZE = "Max survivor size: ([0-9]+)";
  84 
  85     public static void main(String args[]) throws Exception {
  86 
  87         LinkedList<String> options = new LinkedList<>(Arrays.asList(Utils.getTestJavaOpts()));
  88 
  89         // Need to consider the effect of TargetPLABWastePct=1 for G1 GC
  90         if (options.contains("-XX:+UseG1GC")) {
  91             VARIANCE = 2;
  92         } else {
  93             VARIANCE = 1;
  94         }
  95 
  96         negativeTest(-1, options);
  97         negativeTest(101, options);
  98 
  99         positiveTest(20, options);
 100         positiveTest(30, options);
 101         positiveTest(55, options);
 102         positiveTest(70, options);


 116         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
 117         OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
 118 
 119         analyzer.shouldHaveExitValue(1);
 120         analyzer.shouldContain("Error: Could not create the Java Virtual Machine.");
 121     }
 122 
 123     /**
 124      * Verify that actual survivor space usage ratio conforms specified TargetSurvivorRatio
 125      *
 126      * @param ratio value of TargetSurvivorRatio
 127      * @param options additional VM options
 128      */
 129     public static void positiveTest(int ratio, LinkedList<String> options) throws Exception {
 130         LinkedList<String> vmOptions = new LinkedList<>(options);
 131         Collections.addAll(vmOptions,
 132                 "-Xbootclasspath/a:.",
 133                 "-XX:+UnlockDiagnosticVMOptions",
 134                 "-XX:+WhiteBoxAPI",
 135                 "-XX:+UseAdaptiveSizePolicy",
 136                 "-Xlog:gc+age=trace",
 137                 "-XX:MaxTenuringThreshold=" + MAX_TENURING_THRESHOLD,
 138                 "-XX:NewSize=" + MAX_NEW_SIZE,
 139                 "-XX:MaxNewSize=" + MAX_NEW_SIZE,
 140                 "-XX:InitialHeapSize=" + 2 * MAX_NEW_SIZE,
 141                 "-XX:MaxHeapSize=" + 2 * MAX_NEW_SIZE,
 142                 "-XX:SurvivorRatio=" + SURVIVOR_RATIO,
 143                 "-XX:TargetSurvivorRatio=" + ratio,
 144                 // For reducing variance of survivor size.
 145                 "-XX:TargetPLABWastePct=" + 1,
 146                 TargetSurvivorRatioVerifier.class.getName(),
 147                 Integer.toString(ratio)
 148         );
 149 
 150         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
 151         OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start());
 152 
 153         analyzer.shouldHaveExitValue(0);
 154 
 155         String output = analyzer.getOutput();
 156 


< prev index next >