hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java
changeset 27148 a4b542d56e01
child 28219 4fd1bd84c735
equal deleted inserted replaced
27147:ed83dc5777e6 27148:a4b542d56e01
       
     1 /*
       
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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 import com.oracle.java.testlibrary.*;
       
    25 
       
    26 /*
       
    27  * @test CheckCompileThresholdScaling
       
    28  * @bug 8059604
       
    29  * @summary "Add CompileThresholdScalingPercentage flag to control when methods are first compiled (with +/-TieredCompilation)"
       
    30  * @library /testlibrary
       
    31  * @run main CheckCompileThresholdScaling
       
    32  */
       
    33 
       
    34 public class CheckCompileThresholdScaling {
       
    35 
       
    36     // The flag CompileThresholdScaling scales compilation thresholds
       
    37     // in the following way:
       
    38     //
       
    39     // - if CompileThresholdScaling==1.0, the default threshold values
       
    40     // are used;
       
    41     //
       
    42     // - if CompileThresholdScaling>1.0, threshold values are scaled
       
    43     // up (e.g., CompileThresholdScalingPercentage=1.2 scales up
       
    44     // thresholds by a factor of 1.2X);
       
    45     //
       
    46     // - if CompileThresholdScaling<1.0, threshold values are scaled
       
    47     // down;
       
    48     //
       
    49     // - if CompileThresholdScaling==0, compilation is disabled
       
    50     // (equivalent to using -Xint).
       
    51     //
       
    52     // With tiered compilation enabled, the values of the following
       
    53     // flags are changed:
       
    54     //
       
    55     // Tier0InvokeNotifyFreqLog, Tier0BackedgeNotifyFreqLog,
       
    56     // Tier3InvocationThreshold, Tier3MinInvocationThreshold,
       
    57     // Tier3CompileThreshold, and Tier3BackEdgeThreshold,
       
    58     // Tier2InvokeNotifyFreqLog, Tier2BackedgeNotifyFreqLog,
       
    59     // Tier3InvokeNotifyFreqLog, Tier3BackedgeNotifyFreqLog,
       
    60     // Tier23InlineeNotifyFreqLog, Tier4InvocationThreshold,
       
    61     // Tier4MinInvocationThreshold, Tier4CompileThreshold,
       
    62     // Tier4BackEdgeThreshold
       
    63     //
       
    64     // With tiered compilation disabled the value of CompileThreshold
       
    65     // is scaled.
       
    66     private static final String[][] NON_TIERED_ARGUMENTS = {
       
    67         {
       
    68             "-XX:-TieredCompilation",
       
    69             "-XX:+PrintFlagsFinal",
       
    70             "-XX:CompileThreshold=1000",
       
    71             "-version"
       
    72         },
       
    73         {
       
    74             "-XX:-TieredCompilation",
       
    75             "-XX:+PrintFlagsFinal",
       
    76             "-XX:CompileThreshold=1000",
       
    77             "-XX:CompileThresholdScaling=1.25",
       
    78             "-version"
       
    79         },
       
    80         {
       
    81             "-XX:-TieredCompilation",
       
    82             "-XX:+PrintFlagsFinal",
       
    83             "-XX:CompileThreshold=1000",
       
    84             "-XX:CompileThresholdScaling=0.75",
       
    85             "-version"
       
    86         },
       
    87         {
       
    88             "-XX:-TieredCompilation",
       
    89             "-XX:+PrintFlagsFinal",
       
    90             "-XX:CompileThreshold=0",
       
    91             "-XX:CompileThresholdScaling=0.75",
       
    92             "-version"
       
    93         }
       
    94 
       
    95     };
       
    96 
       
    97     private static final String[][] NON_TIERED_EXPECTED_OUTPUTS = {
       
    98         {
       
    99             "intx CompileThreshold                         := 1000                                {pd product}",
       
   100             "double CompileThresholdScaling                   = 1.000000                            {product}"
       
   101         },
       
   102         {
       
   103             "intx CompileThreshold                         := 1250                                {pd product}",
       
   104             "double CompileThresholdScaling                  := 1.250000                            {product}"
       
   105         },
       
   106         {
       
   107             "intx CompileThreshold                         := 750                                 {pd product}",
       
   108             "double CompileThresholdScaling                  := 0.750000                            {product}"
       
   109         },
       
   110         {
       
   111             "intx CompileThreshold                         := 0                                   {pd product}",
       
   112             "double CompileThresholdScaling                  := 0.750000                            {product}",
       
   113             "interpreted mode"
       
   114         }
       
   115     };
       
   116 
       
   117     private static final String[][] TIERED_ARGUMENTS = {
       
   118         {
       
   119             "-XX:+TieredCompilation",
       
   120             "-XX:+PrintFlagsFinal",
       
   121             "-XX:Tier0InvokeNotifyFreqLog=7",
       
   122             "-XX:Tier0BackedgeNotifyFreqLog=10",
       
   123             "-XX:Tier3InvocationThreshold=200",
       
   124             "-XX:Tier3MinInvocationThreshold=100",
       
   125             "-XX:Tier3CompileThreshold=2000",
       
   126             "-XX:Tier3BackEdgeThreshold=60000",
       
   127             "-XX:Tier2InvokeNotifyFreqLog=11",
       
   128             "-XX:Tier2BackedgeNotifyFreqLog=14",
       
   129             "-XX:Tier3InvokeNotifyFreqLog=10",
       
   130             "-XX:Tier3BackedgeNotifyFreqLog=13",
       
   131             "-XX:Tier23InlineeNotifyFreqLog=20",
       
   132             "-XX:Tier4InvocationThreshold=5000",
       
   133             "-XX:Tier4MinInvocationThreshold=600",
       
   134             "-XX:Tier4CompileThreshold=15000",
       
   135             "-XX:Tier4BackEdgeThreshold=40000",
       
   136             "-version"
       
   137         },
       
   138         {
       
   139             "-XX:+TieredCompilation",
       
   140             "-XX:+PrintFlagsFinal",
       
   141             "-XX:Tier0InvokeNotifyFreqLog=7",
       
   142             "-XX:Tier0BackedgeNotifyFreqLog=10",
       
   143             "-XX:Tier3InvocationThreshold=200",
       
   144             "-XX:Tier3MinInvocationThreshold=100",
       
   145             "-XX:Tier3CompileThreshold=2000",
       
   146             "-XX:Tier3BackEdgeThreshold=60000",
       
   147             "-XX:Tier2InvokeNotifyFreqLog=11",
       
   148             "-XX:Tier2BackedgeNotifyFreqLog=14",
       
   149             "-XX:Tier3InvokeNotifyFreqLog=10",
       
   150             "-XX:Tier3BackedgeNotifyFreqLog=13",
       
   151             "-XX:Tier23InlineeNotifyFreqLog=20",
       
   152             "-XX:Tier4InvocationThreshold=5000",
       
   153             "-XX:Tier4MinInvocationThreshold=600",
       
   154             "-XX:Tier4CompileThreshold=15000",
       
   155             "-XX:Tier4BackEdgeThreshold=40000",
       
   156             "-XX:CompileThresholdScaling=0.75",
       
   157             "-version"
       
   158         },
       
   159         {
       
   160             "-XX:+TieredCompilation",
       
   161             "-XX:+PrintFlagsFinal",
       
   162             "-XX:Tier0InvokeNotifyFreqLog=7",
       
   163             "-XX:Tier0BackedgeNotifyFreqLog=10",
       
   164             "-XX:Tier3InvocationThreshold=200",
       
   165             "-XX:Tier3MinInvocationThreshold=100",
       
   166             "-XX:Tier3CompileThreshold=2000",
       
   167             "-XX:Tier3BackEdgeThreshold=60000",
       
   168             "-XX:Tier2InvokeNotifyFreqLog=11",
       
   169             "-XX:Tier2BackedgeNotifyFreqLog=14",
       
   170             "-XX:Tier3InvokeNotifyFreqLog=10",
       
   171             "-XX:Tier3BackedgeNotifyFreqLog=13",
       
   172             "-XX:Tier23InlineeNotifyFreqLog=20",
       
   173             "-XX:Tier4InvocationThreshold=5000",
       
   174             "-XX:Tier4MinInvocationThreshold=600",
       
   175             "-XX:Tier4CompileThreshold=15000",
       
   176             "-XX:Tier4BackEdgeThreshold=40000",
       
   177             "-XX:CompileThresholdScaling=1.25",
       
   178             "-version"
       
   179         },
       
   180         {
       
   181             "-XX:+TieredCompilation",
       
   182             "-XX:+PrintFlagsFinal",
       
   183             "-XX:Tier0InvokeNotifyFreqLog=7",
       
   184             "-XX:Tier0BackedgeNotifyFreqLog=10",
       
   185             "-XX:Tier3InvocationThreshold=200",
       
   186             "-XX:Tier3MinInvocationThreshold=100",
       
   187             "-XX:Tier3CompileThreshold=2000",
       
   188             "-XX:Tier3BackEdgeThreshold=60000",
       
   189             "-XX:Tier2InvokeNotifyFreqLog=11",
       
   190             "-XX:Tier2BackedgeNotifyFreqLog=14",
       
   191             "-XX:Tier3InvokeNotifyFreqLog=10",
       
   192             "-XX:Tier3BackedgeNotifyFreqLog=13",
       
   193             "-XX:Tier23InlineeNotifyFreqLog=20",
       
   194             "-XX:Tier4InvocationThreshold=5000",
       
   195             "-XX:Tier4MinInvocationThreshold=600",
       
   196             "-XX:Tier4CompileThreshold=15000",
       
   197             "-XX:Tier4BackEdgeThreshold=40000",
       
   198             "-XX:CompileThresholdScaling=2.0",
       
   199             "-version"
       
   200         },
       
   201         {
       
   202             "-XX:+TieredCompilation",
       
   203             "-XX:+PrintFlagsFinal",
       
   204             "-XX:Tier0InvokeNotifyFreqLog=7",
       
   205             "-XX:Tier0BackedgeNotifyFreqLog=10",
       
   206             "-XX:Tier3InvocationThreshold=200",
       
   207             "-XX:Tier3MinInvocationThreshold=100",
       
   208             "-XX:Tier3CompileThreshold=2000",
       
   209             "-XX:Tier3BackEdgeThreshold=60000",
       
   210             "-XX:Tier2InvokeNotifyFreqLog=11",
       
   211             "-XX:Tier2BackedgeNotifyFreqLog=14",
       
   212             "-XX:Tier3InvokeNotifyFreqLog=10",
       
   213             "-XX:Tier3BackedgeNotifyFreqLog=13",
       
   214             "-XX:Tier23InlineeNotifyFreqLog=20",
       
   215             "-XX:Tier4InvocationThreshold=5000",
       
   216             "-XX:Tier4MinInvocationThreshold=600",
       
   217             "-XX:Tier4CompileThreshold=15000",
       
   218             "-XX:Tier4BackEdgeThreshold=40000",
       
   219             "-XX:CompileThresholdScaling=0.0",
       
   220             "-version"
       
   221         }
       
   222     };
       
   223 
       
   224     private static final String[][] TIERED_EXPECTED_OUTPUTS = {
       
   225         {
       
   226             "intx Tier0BackedgeNotifyFreqLog               := 10                                  {product}",
       
   227             "intx Tier0InvokeNotifyFreqLog                 := 7                                   {product}",
       
   228             "intx Tier23InlineeNotifyFreqLog               := 20                                  {product}",
       
   229             "intx Tier2BackedgeNotifyFreqLog               := 14                                  {product}",
       
   230             "intx Tier2InvokeNotifyFreqLog                 := 11                                  {product}",
       
   231             "intx Tier3BackEdgeThreshold                   := 60000                               {product}",
       
   232             "intx Tier3BackedgeNotifyFreqLog               := 13                                  {product}",
       
   233             "intx Tier3CompileThreshold                    := 2000                                {product}",
       
   234             "intx Tier3InvocationThreshold                 := 200                                 {product}",
       
   235             "intx Tier3InvokeNotifyFreqLog                 := 10                                  {product}",
       
   236             "intx Tier3MinInvocationThreshold              := 100                                 {product}",
       
   237             "intx Tier4BackEdgeThreshold                   := 40000                               {product}",
       
   238             "intx Tier4CompileThreshold                    := 15000                               {product}",
       
   239             "intx Tier4InvocationThreshold                 := 5000                                {product}",
       
   240             "intx Tier4MinInvocationThreshold              := 600                                 {product}",
       
   241             "double CompileThresholdScaling                   = 1.000000                            {product}"
       
   242         },
       
   243         {
       
   244             "intx Tier0BackedgeNotifyFreqLog               := 9                                   {product}",
       
   245             "intx Tier0InvokeNotifyFreqLog                 := 6                                   {product}",
       
   246             "intx Tier23InlineeNotifyFreqLog               := 19                                  {product}",
       
   247             "intx Tier2BackedgeNotifyFreqLog               := 13                                  {product}",
       
   248             "intx Tier2InvokeNotifyFreqLog                 := 10                                  {product}",
       
   249             "intx Tier3BackEdgeThreshold                   := 45000                               {product}",
       
   250             "intx Tier3BackedgeNotifyFreqLog               := 12                                  {product}",
       
   251             "intx Tier3CompileThreshold                    := 1500                                {product}",
       
   252             "intx Tier3InvocationThreshold                 := 150                                 {product}",
       
   253             "intx Tier3InvokeNotifyFreqLog                 := 9                                   {product}",
       
   254             "intx Tier3MinInvocationThreshold              := 75                                  {product}",
       
   255             "intx Tier4BackEdgeThreshold                   := 30000                               {product}",
       
   256             "intx Tier4CompileThreshold                    := 11250                               {product}",
       
   257             "intx Tier4InvocationThreshold                 := 3750                                {product}",
       
   258             "intx Tier4MinInvocationThreshold              := 450                                 {product}",
       
   259             "double CompileThresholdScaling                  := 0.750000                            {product}"
       
   260         },
       
   261         {
       
   262             "intx Tier0BackedgeNotifyFreqLog               := 10                                  {product}",
       
   263             "intx Tier0InvokeNotifyFreqLog                 := 7                                   {product}",
       
   264             "intx Tier23InlineeNotifyFreqLog               := 20                                  {product}",
       
   265             "intx Tier2BackedgeNotifyFreqLog               := 14                                  {product}",
       
   266             "intx Tier2InvokeNotifyFreqLog                 := 11                                  {product}",
       
   267             "intx Tier3BackEdgeThreshold                   := 75000                               {product}",
       
   268             "intx Tier3BackedgeNotifyFreqLog               := 13                                  {product}",
       
   269             "intx Tier3CompileThreshold                    := 2500                                {product}",
       
   270             "intx Tier3InvocationThreshold                 := 250                                 {product}",
       
   271             "intx Tier3InvokeNotifyFreqLog                 := 10                                  {product}",
       
   272             "intx Tier3MinInvocationThreshold              := 125                                 {product}",
       
   273             "intx Tier4BackEdgeThreshold                   := 50000                               {product}",
       
   274             "intx Tier4CompileThreshold                    := 18750                               {product}",
       
   275             "intx Tier4InvocationThreshold                 := 6250                                {product}",
       
   276             "intx Tier4MinInvocationThreshold              := 750                                 {product}",
       
   277             "double CompileThresholdScaling                  := 1.250000                            {product}"
       
   278         },
       
   279         {
       
   280             "intx Tier0BackedgeNotifyFreqLog               := 11                                  {product}",
       
   281             "intx Tier0InvokeNotifyFreqLog                 := 8                                   {product}",
       
   282             "intx Tier23InlineeNotifyFreqLog               := 21                                  {product}",
       
   283             "intx Tier2BackedgeNotifyFreqLog               := 15                                  {product}",
       
   284             "intx Tier2InvokeNotifyFreqLog                 := 12                                  {product}",
       
   285             "intx Tier3BackEdgeThreshold                   := 120000                              {product}",
       
   286             "intx Tier3BackedgeNotifyFreqLog               := 14                                  {product}",
       
   287             "intx Tier3CompileThreshold                    := 4000                                {product}",
       
   288             "intx Tier3InvocationThreshold                 := 400                                 {product}",
       
   289             "intx Tier3InvokeNotifyFreqLog                 := 11                                  {product}",
       
   290             "intx Tier3MinInvocationThreshold              := 200                                 {product}",
       
   291             "intx Tier4BackEdgeThreshold                   := 80000                               {product}",
       
   292             "intx Tier4CompileThreshold                    := 30000                               {product}",
       
   293             "intx Tier4InvocationThreshold                 := 10000                               {product}",
       
   294             "intx Tier4MinInvocationThreshold              := 1200                                {product}",
       
   295             "double CompileThresholdScaling                  := 2.000000                            {product}"
       
   296         },
       
   297         {
       
   298             "intx Tier0BackedgeNotifyFreqLog               := 0                                   {product}",
       
   299             "intx Tier0InvokeNotifyFreqLog                 := 0                                   {product}",
       
   300             "intx Tier23InlineeNotifyFreqLog               := 0                                   {product}",
       
   301             "intx Tier2BackedgeNotifyFreqLog               := 0                                   {product}",
       
   302             "intx Tier2InvokeNotifyFreqLog                 := 0                                   {product}",
       
   303             "intx Tier3BackEdgeThreshold                   := 0                                   {product}",
       
   304             "intx Tier3BackedgeNotifyFreqLog               := 0                                   {product}",
       
   305             "intx Tier3CompileThreshold                    := 0                                   {product}",
       
   306             "intx Tier3InvocationThreshold                 := 0                                   {product}",
       
   307             "intx Tier3InvokeNotifyFreqLog                 := 0                                   {product}",
       
   308             "intx Tier3MinInvocationThreshold              := 0                                   {product}",
       
   309             "intx Tier4BackEdgeThreshold                   := 0                                   {product}",
       
   310             "intx Tier4CompileThreshold                    := 0                                   {product}",
       
   311             "intx Tier4InvocationThreshold                 := 0                                   {product}",
       
   312             "intx Tier4MinInvocationThreshold              := 0                                   {product}",
       
   313             "double CompileThresholdScaling                  := 0.000000                            {product}",
       
   314             "interpreted mode"
       
   315         }
       
   316     };
       
   317 
       
   318     private static void verifyValidOption(String[] arguments, String[] expected_outputs, boolean tiered) throws Exception {
       
   319         ProcessBuilder pb;
       
   320         OutputAnalyzer out;
       
   321 
       
   322         pb = ProcessTools.createJavaProcessBuilder(arguments);
       
   323         out = new OutputAnalyzer(pb.start());
       
   324 
       
   325         try {
       
   326             for (String expected_output : expected_outputs) {
       
   327                 out.shouldContain(expected_output);
       
   328             }
       
   329             out.shouldHaveExitValue(0);
       
   330         } catch (RuntimeException e) {
       
   331             // Check if tiered compilation is available in this JVM
       
   332             // Version. Throw exception only if it is available.
       
   333             if (!(tiered && out.getOutput().contains("Client VM warning: TieredCompilation is disabled in this release."))) {
       
   334                 throw new RuntimeException(e);
       
   335             }
       
   336         }
       
   337     }
       
   338 
       
   339     public static void main(String[] args) throws Exception {
       
   340 
       
   341         if (NON_TIERED_ARGUMENTS.length != NON_TIERED_EXPECTED_OUTPUTS.length) {
       
   342             throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in non-tiered mode of operation does not match.");
       
   343         }
       
   344 
       
   345         if (TIERED_ARGUMENTS.length != TIERED_EXPECTED_OUTPUTS.length) {
       
   346             throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in tiered mode of operation.");
       
   347         }
       
   348 
       
   349         // Check if thresholds are scaled properly in non-tiered mode of operation
       
   350         for (int i = 0; i < NON_TIERED_ARGUMENTS.length; i++) {
       
   351             verifyValidOption(NON_TIERED_ARGUMENTS[i], NON_TIERED_EXPECTED_OUTPUTS[i], false);
       
   352         }
       
   353 
       
   354         // Check if thresholds are scaled properly in tiered mode of operation
       
   355         for (int i = 0; i < TIERED_ARGUMENTS.length; i++) {
       
   356             verifyValidOption(TIERED_ARGUMENTS[i], TIERED_EXPECTED_OUTPUTS[i], true);
       
   357         }
       
   358     }
       
   359 }