< prev index next >

test/gc/g1/TestRemsetLoggingThreads.java

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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  * @test TestSummarizeRSetStatsThreads
  26  * @bug 8025441
  27  * @summary Ensure that various values of worker threads/concurrent
  28  * refinement threads do not crash the VM.
  29  * @key gc
  30  * @library /testlibrary
  31  * @modules java.base/sun.misc
  32  *          java.management/sun.management
  33  */
  34 
  35 import java.util.regex.Matcher;
  36 import java.util.regex.Pattern;
  37 
  38 import jdk.test.lib.ProcessTools;
  39 import jdk.test.lib.OutputAnalyzer;
  40 
  41 public class TestSummarizeRSetStatsThreads {
  42 
  43   private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  44     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
  45                                                               "-XX:+UnlockDiagnosticVMOptions",
  46                                                               "-XX:+G1SummarizeRSetStats",
  47                                                               "-XX:G1ConcRefinementThreads=" + refinementThreads,
  48                                                               "-XX:ParallelGCThreads=" + workerThreads,
  49                                                               "-version");
  50 
  51     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  52 
  53     // check output to contain the string "Concurrent RS threads times (s)" followed by
  54     // the correct number of values in the next line.
  55 
  56     // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  57     // Additionally use at least one thread.
  58     int expectedNumRefinementThreads = refinementThreads;
  59 
  60     // create the pattern made up of n copies of a floating point number pattern
  61     String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0)
  62       .replace("0", "\\s+\\d+\\.\\d+");
  63     String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$";
  64     Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());
  65 
  66     if (!m.find()) {
  67       throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
  68         " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  69     }
  70     output.shouldHaveExitValue(0);
  71   }
  72 
  73   public static void main(String[] args) throws Exception {
  74     if (!TestSummarizeRSetStatsTools.testingG1GC()) {
  75       return;
  76     }
  77     // different valid combinations of number of refinement and gc worker threads
  78     runTest(1, 1);
  79     runTest(1, 5);
  80     runTest(5, 1);
  81     runTest(10, 10);
  82     runTest(1, 2);
  83     runTest(4, 3);
  84   }
  85 }


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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  * @test TestRemsetLoggingThreads
  26  * @bug 8025441
  27  * @summary Ensure that various values of worker threads/concurrent
  28  * refinement threads do not crash the VM.
  29  * @key gc
  30  * @library /testlibrary
  31  * @modules java.base/sun.misc
  32  *          java.management/sun.management
  33  */
  34 
  35 import java.util.regex.Matcher;
  36 import java.util.regex.Pattern;
  37 
  38 import jdk.test.lib.ProcessTools;
  39 import jdk.test.lib.OutputAnalyzer;
  40 
  41 public class TestRemsetLoggingThreads {
  42 
  43   private static void runTest(int refinementThreads, int workerThreads) throws Exception {
  44     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
  45                                                               "-XX:+UnlockDiagnosticVMOptions",
  46                                                               "-Xlog:gc+remset+exit=trace",
  47                                                               "-XX:G1ConcRefinementThreads=" + refinementThreads,
  48                                                               "-XX:ParallelGCThreads=" + workerThreads,
  49                                                               "-version");
  50 
  51     OutputAnalyzer output = new OutputAnalyzer(pb.start());
  52 



  53     // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
  54     // Additionally use at least one thread.
  55     int expectedNumRefinementThreads = refinementThreads;
  56 
  57     String pattern = "Concurrent RS threads times \\(s\\)$";



  58     Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());
  59 
  60     if (!m.find()) {
  61       throw new Exception("Could not find correct output for concurrent RS threads times in stdout," +
  62         " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
  63     }
  64     output.shouldHaveExitValue(0);
  65   }
  66 
  67   public static void main(String[] args) throws Exception {
  68     if (!TestRemsetLoggingTools.testingG1GC()) {
  69       return;
  70     }
  71     // different valid combinations of number of refinement and gc worker threads
  72     runTest(1, 1);
  73     runTest(1, 5);
  74     runTest(5, 1);
  75     runTest(10, 10);
  76     runTest(1, 2);
  77     runTest(4, 3);
  78   }
  79 }
< prev index next >