< prev index next >

test/gc/g1/plab/TestPLABResize.java

Print this page




 106      *
 107      * @param output - VM output
 108      * @param testCase
 109      */
 110     private static void checkResults(String output, TestCase testCase) {
 111         final LogParser log = new LogParser(output);
 112         final Map<Long, Map<LogParser.ReportType, Map<String, Long>>> entries = log.getEntries();
 113 
 114         final ArrayList<Long> plabSizes = entries.entrySet()
 115                 .stream()
 116                 .map(item -> {
 117                     return item.getValue()
 118                             .get(LogParser.ReportType.SURVIVOR_STATS)
 119                             .get("desired_plab_sz");
 120                 })
 121                 .collect(Collectors.toCollection(ArrayList::new));
 122 
 123         // Check that desired plab size was changed during iterations.
 124         // It should decrease during first half of iterations
 125         // and increase after.
 126         List<Long> decreasedPlabs = plabSizes.subList(testCase.getIterations(), testCase.getIterations() * 2);
 127         List<Long> increasedPlabs = plabSizes.subList(testCase.getIterations() * 2, testCase.getIterations() * 3);
 128 
 129         Long prev = decreasedPlabs.get(0);
 130         for (int index = 1; index < decreasedPlabs.size(); ++index) {
 131             Long current = decreasedPlabs.get(index);
 132             if (prev < current) {
 133                 System.out.println(output);
 134                 throw new RuntimeException("Test failed! Expect that previous PLAB size should be greater than current. Prev.size: " + prev + " Current size:" + current);
 135             }
 136             prev = current;
 137         }
 138 
 139         prev = increasedPlabs.get(0);
 140         for (int index = 1; index < increasedPlabs.size(); ++index) {
 141             Long current = increasedPlabs.get(index);
 142             if (prev > current) {
 143                 System.out.println(output);
 144                 throw new RuntimeException("Test failed! Expect that previous PLAB size should be less than current. Prev.size: " + prev + " Current size:" + current);
 145             }
 146             prev = current;
 147         }
 148 
 149         System.out.println("Test passed!");
 150     }
 151 
 152     /**
 153      * Description of one test case.
 154      */
 155     private static class TestCase {
 156 
 157         private final int wastePct;
 158         private final int chunkSize;
 159         private final int parGCThreads;
 160         private final int iterations;
 161 
 162         /**
 163          * @param wastePct
 164          * ParallelGCBufferWastePct
 165          * @param chunkSize
 166          * requested object size for memory consumption


 177             if (wastePct == 0 || chunkSize == 0 || parGCThreads == 0 || iterations == 0) {
 178                 throw new IllegalArgumentException("Parameters should not be 0");
 179             }
 180             this.wastePct = wastePct;
 181 
 182             this.chunkSize = chunkSize;
 183             this.parGCThreads = parGCThreads;
 184             this.iterations = iterations;
 185         }
 186 
 187         /**
 188          * Convert current TestCase to List of options.
 189          *
 190          * @return
 191          * List of options
 192          */
 193         public List<String> toOptions() {
 194             return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads,
 195                     "-XX:ParallelGCBufferWastePct=" + wastePct,
 196                     "-XX:+ResizePLAB",
 197                     "-Dthreads=" + parGCThreads,
 198                     "-Dchunk.size=" + chunkSize,
 199                     "-Diterations=" + iterations,
 200                     "-XX:NewSize=16m",
 201                     "-XX:MaxNewSize=16m"
 202             );
 203         }
 204 
 205         /**
 206          * Print details about test case.
 207          */
 208         public void print(PrintStream out) {
 209             out.println("Test case details:");
 210             out.println("  Parallel GC buffer waste pct : " + wastePct);
 211             out.println("  Chunk size : " + chunkSize);
 212             out.println("  Parallel GC threads : " + parGCThreads);
 213             out.println("  Iterations: " + iterations);
 214         }
 215 
 216         /**
 217          * @return iterations


 106      *
 107      * @param output - VM output
 108      * @param testCase
 109      */
 110     private static void checkResults(String output, TestCase testCase) {
 111         final LogParser log = new LogParser(output);
 112         final Map<Long, Map<LogParser.ReportType, Map<String, Long>>> entries = log.getEntries();
 113 
 114         final ArrayList<Long> plabSizes = entries.entrySet()
 115                 .stream()
 116                 .map(item -> {
 117                     return item.getValue()
 118                             .get(LogParser.ReportType.SURVIVOR_STATS)
 119                             .get("desired_plab_sz");
 120                 })
 121                 .collect(Collectors.toCollection(ArrayList::new));
 122 
 123         // Check that desired plab size was changed during iterations.
 124         // It should decrease during first half of iterations
 125         // and increase after.
 126         long startDesiredPLABSize = plabSizes.get(testCase.getIterations());
 127         long endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2 - 1);
 128 
 129         if (startDesiredPLABSize < endDesiredPLABSize) {



 130             System.out.println(output);
 131             throw new RuntimeException("Test failed! Expect that initial PLAB size should be greater than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize);


 132         }
 133 
 134         startDesiredPLABSize = plabSizes.get(testCase.getIterations() * 2);
 135         endDesiredPLABSize = plabSizes.get(testCase.getIterations() * 3 - 1);
 136 
 137         if (startDesiredPLABSize > endDesiredPLABSize) {
 138             System.out.println(output);
 139             throw new RuntimeException("Test failed! Expect that initial PLAB size should be less than checked. Initial size: " + startDesiredPLABSize + " Checked size:" + endDesiredPLABSize);


 140         }
 141 
 142         System.out.println("Test passed!");
 143     }
 144 
 145     /**
 146      * Description of one test case.
 147      */
 148     private static class TestCase {
 149 
 150         private final int wastePct;
 151         private final int chunkSize;
 152         private final int parGCThreads;
 153         private final int iterations;
 154 
 155         /**
 156          * @param wastePct
 157          * ParallelGCBufferWastePct
 158          * @param chunkSize
 159          * requested object size for memory consumption


 170             if (wastePct == 0 || chunkSize == 0 || parGCThreads == 0 || iterations == 0) {
 171                 throw new IllegalArgumentException("Parameters should not be 0");
 172             }
 173             this.wastePct = wastePct;
 174 
 175             this.chunkSize = chunkSize;
 176             this.parGCThreads = parGCThreads;
 177             this.iterations = iterations;
 178         }
 179 
 180         /**
 181          * Convert current TestCase to List of options.
 182          *
 183          * @return
 184          * List of options
 185          */
 186         public List<String> toOptions() {
 187             return Arrays.asList("-XX:ParallelGCThreads=" + parGCThreads,
 188                     "-XX:ParallelGCBufferWastePct=" + wastePct,
 189                     "-XX:+ResizePLAB",

 190                     "-Dchunk.size=" + chunkSize,
 191                     "-Diterations=" + iterations,
 192                     "-XX:NewSize=16m",
 193                     "-XX:MaxNewSize=16m"
 194             );
 195         }
 196 
 197         /**
 198          * Print details about test case.
 199          */
 200         public void print(PrintStream out) {
 201             out.println("Test case details:");
 202             out.println("  Parallel GC buffer waste pct : " + wastePct);
 203             out.println("  Chunk size : " + chunkSize);
 204             out.println("  Parallel GC threads : " + parGCThreads);
 205             out.println("  Iterations: " + iterations);
 206         }
 207 
 208         /**
 209          * @return iterations
< prev index next >