Path: blob/master/test/hotspot/jtreg/compiler/arguments/CheckCompileThresholdScaling.java
41152 views
/*1* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test CheckCompileThresholdScaling25* @bug 805960426* @summary Add CompileThresholdScaling flag to control when methods are first compiled (with +/-TieredCompilation)27* @library /test/lib28* @requires vm.flagless29* @modules java.base/jdk.internal.misc30* java.management31*32* @run driver compiler.arguments.CheckCompileThresholdScaling33*/3435package compiler.arguments;3637import jdk.test.lib.process.OutputAnalyzer;38import jdk.test.lib.process.ProcessTools;3940public class CheckCompileThresholdScaling {4142// The flag CompileThresholdScaling scales compilation thresholds43// in the following way:44//45// - if CompileThresholdScaling==1.0, the default threshold values46// are used;47//48// - if CompileThresholdScaling>1.0, threshold values are scaled49// up (e.g., CompileThresholdScalingPercentage=1.2 scales up50// thresholds by a factor of 1.2X);51//52// - if CompileThresholdScaling<1.0, threshold values are scaled53// down;54//55// - if CompileThresholdScaling==0, compilation is disabled56// (equivalent to using -Xint).57//58// With tiered compilation enabled, the values of the following59// flags are changed:60//61// Tier0InvokeNotifyFreqLog, Tier0BackedgeNotifyFreqLog,62// Tier3InvocationThreshold, Tier3MinInvocationThreshold,63// Tier3CompileThreshold, Tier3BackEdgeThreshold,64// Tier2InvokeNotifyFreqLog, Tier2BackedgeNotifyFreqLog,65// Tier3InvokeNotifyFreqLog, Tier3BackedgeNotifyFreqLog,66// Tier23InlineeNotifyFreqLog, Tier4InvocationThreshold,67// Tier4MinInvocationThreshold, Tier4CompileThreshold,68// Tier4BackEdgeThreshold69//70// With tiered compilation disabled the value of CompileThreshold71// is scaled.72private static final String[][] NON_TIERED_ARGUMENTS = {73{74"-XX:-TieredCompilation",75"-XX:+PrintFlagsFinal",76"-XX:CompileThreshold=1000",77"-version"78},79{80"-XX:-TieredCompilation",81"-XX:+PrintFlagsFinal",82"-XX:CompileThreshold=1000",83"-XX:CompileThresholdScaling=1.25",84"-version"85},86{87"-XX:-TieredCompilation",88"-XX:+PrintFlagsFinal",89"-XX:CompileThreshold=1000",90"-XX:CompileThresholdScaling=0.75",91"-version"92},93{94"-XX:-TieredCompilation",95"-XX:+PrintFlagsFinal",96"-XX:CompileThreshold=1000",97"-XX:CompileThresholdScaling=0.0",98"-version"99},100{101"-XX:-TieredCompilation",102"-XX:+PrintFlagsFinal",103"-XX:CompileThreshold=0",104"-XX:CompileThresholdScaling=0.75",105"-version"106}107108};109110private static final String[][] NON_TIERED_EXPECTED_OUTPUTS = {111{112"intx CompileThreshold = 1000 {pd product} {command line}",113"double CompileThresholdScaling = 1.000000 {product} {default}"114},115{116"intx CompileThreshold = 1250 {pd product} {command line, ergonomic}",117"double CompileThresholdScaling = 1.250000 {product} {command line}"118},119{120"intx CompileThreshold = 750 {pd product} {command line, ergonomic}",121"double CompileThresholdScaling = 0.750000 {product} {command line}"122},123{124"intx CompileThreshold = 1000 {pd product} {command line}",125"double CompileThresholdScaling = 0.000000 {product} {command line}",126"interpreted mode"127},128{129"intx CompileThreshold = 0 {pd product} {command line}",130"double CompileThresholdScaling = 0.750000 {product} {command line}",131"interpreted mode"132}133};134135private static final String[][] TIERED_ARGUMENTS = {136{137"-XX:+TieredCompilation",138"-XX:+PrintFlagsFinal",139"-XX:Tier0InvokeNotifyFreqLog=7",140"-XX:Tier0BackedgeNotifyFreqLog=10",141"-XX:Tier3InvocationThreshold=200",142"-XX:Tier3MinInvocationThreshold=100",143"-XX:Tier3CompileThreshold=2000",144"-XX:Tier3BackEdgeThreshold=60000",145"-XX:Tier2InvokeNotifyFreqLog=11",146"-XX:Tier2BackedgeNotifyFreqLog=14",147"-XX:Tier3InvokeNotifyFreqLog=10",148"-XX:Tier3BackedgeNotifyFreqLog=13",149"-XX:Tier23InlineeNotifyFreqLog=20",150"-XX:Tier4InvocationThreshold=5000",151"-XX:Tier4MinInvocationThreshold=600",152"-XX:Tier4CompileThreshold=15000",153"-XX:Tier4BackEdgeThreshold=40000",154"-version"155},156{157"-XX:+TieredCompilation",158"-XX:+PrintFlagsFinal",159"-XX:Tier0InvokeNotifyFreqLog=7",160"-XX:Tier0BackedgeNotifyFreqLog=10",161"-XX:Tier3InvocationThreshold=200",162"-XX:Tier3MinInvocationThreshold=100",163"-XX:Tier3CompileThreshold=2000",164"-XX:Tier3BackEdgeThreshold=60000",165"-XX:Tier2InvokeNotifyFreqLog=11",166"-XX:Tier2BackedgeNotifyFreqLog=14",167"-XX:Tier3InvokeNotifyFreqLog=10",168"-XX:Tier3BackedgeNotifyFreqLog=13",169"-XX:Tier23InlineeNotifyFreqLog=20",170"-XX:Tier4InvocationThreshold=5000",171"-XX:Tier4MinInvocationThreshold=600",172"-XX:Tier4CompileThreshold=15000",173"-XX:Tier4BackEdgeThreshold=40000",174"-XX:CompileThresholdScaling=0.75",175"-version"176},177{178"-XX:+TieredCompilation",179"-XX:+PrintFlagsFinal",180"-XX:Tier0InvokeNotifyFreqLog=7",181"-XX:Tier0BackedgeNotifyFreqLog=10",182"-XX:Tier3InvocationThreshold=200",183"-XX:Tier3MinInvocationThreshold=100",184"-XX:Tier3CompileThreshold=2000",185"-XX:Tier3BackEdgeThreshold=60000",186"-XX:Tier2InvokeNotifyFreqLog=11",187"-XX:Tier2BackedgeNotifyFreqLog=14",188"-XX:Tier3InvokeNotifyFreqLog=10",189"-XX:Tier3BackedgeNotifyFreqLog=13",190"-XX:Tier23InlineeNotifyFreqLog=20",191"-XX:Tier4InvocationThreshold=5000",192"-XX:Tier4MinInvocationThreshold=600",193"-XX:Tier4CompileThreshold=15000",194"-XX:Tier4BackEdgeThreshold=40000",195"-XX:CompileThresholdScaling=1.25",196"-version"197},198{199"-XX:+TieredCompilation",200"-XX:+PrintFlagsFinal",201"-XX:Tier0InvokeNotifyFreqLog=7",202"-XX:Tier0BackedgeNotifyFreqLog=10",203"-XX:Tier3InvocationThreshold=200",204"-XX:Tier3MinInvocationThreshold=100",205"-XX:Tier3CompileThreshold=2000",206"-XX:Tier3BackEdgeThreshold=60000",207"-XX:Tier2InvokeNotifyFreqLog=11",208"-XX:Tier2BackedgeNotifyFreqLog=14",209"-XX:Tier3InvokeNotifyFreqLog=10",210"-XX:Tier3BackedgeNotifyFreqLog=13",211"-XX:Tier23InlineeNotifyFreqLog=20",212"-XX:Tier4InvocationThreshold=5000",213"-XX:Tier4MinInvocationThreshold=600",214"-XX:Tier4CompileThreshold=15000",215"-XX:Tier4BackEdgeThreshold=40000",216"-XX:CompileThresholdScaling=2.0",217"-version"218},219{220"-XX:+TieredCompilation",221"-XX:+PrintFlagsFinal",222"-XX:Tier0InvokeNotifyFreqLog=7",223"-XX:Tier0BackedgeNotifyFreqLog=10",224"-XX:Tier3InvocationThreshold=200",225"-XX:Tier3MinInvocationThreshold=100",226"-XX:Tier3CompileThreshold=2000",227"-XX:Tier3BackEdgeThreshold=60000",228"-XX:Tier2InvokeNotifyFreqLog=11",229"-XX:Tier2BackedgeNotifyFreqLog=14",230"-XX:Tier3InvokeNotifyFreqLog=10",231"-XX:Tier3BackedgeNotifyFreqLog=13",232"-XX:Tier23InlineeNotifyFreqLog=20",233"-XX:Tier4InvocationThreshold=5000",234"-XX:Tier4MinInvocationThreshold=600",235"-XX:Tier4CompileThreshold=15000",236"-XX:Tier4BackEdgeThreshold=40000",237"-XX:CompileThresholdScaling=0.0",238"-version"239}240};241242private static final String[][] TIERED_EXPECTED_OUTPUTS = {243{244"intx Tier0BackedgeNotifyFreqLog = 10 {product} {command line}",245"intx Tier0InvokeNotifyFreqLog = 7 {product} {command line}",246"intx Tier23InlineeNotifyFreqLog = 20 {product} {command line}",247"intx Tier2BackedgeNotifyFreqLog = 14 {product} {command line}",248"intx Tier2InvokeNotifyFreqLog = 11 {product} {command line}",249"intx Tier3BackEdgeThreshold = 60000 {product} {command line}",250"intx Tier3BackedgeNotifyFreqLog = 13 {product} {command line}",251"intx Tier3CompileThreshold = 2000 {product} {command line}",252"intx Tier3InvocationThreshold = 200 {product} {command line}",253"intx Tier3InvokeNotifyFreqLog = 10 {product} {command line}",254"intx Tier3MinInvocationThreshold = 100 {product} {command line}",255"intx Tier4BackEdgeThreshold = 40000 {product} {command line}",256"intx Tier4CompileThreshold = 15000 {product} {command line}",257"intx Tier4InvocationThreshold = 5000 {product} {command line}",258"intx Tier4MinInvocationThreshold = 600 {product} {command line}",259"double CompileThresholdScaling = 1.000000 {product} {default}"260},261{262"intx Tier0BackedgeNotifyFreqLog = 9 {product} {command line, ergonomic}",263"intx Tier0InvokeNotifyFreqLog = 6 {product} {command line, ergonomic}",264"intx Tier23InlineeNotifyFreqLog = 19 {product} {command line, ergonomic}",265"intx Tier2BackedgeNotifyFreqLog = 13 {product} {command line, ergonomic}",266"intx Tier2InvokeNotifyFreqLog = 10 {product} {command line, ergonomic}",267"intx Tier3BackEdgeThreshold = 45000 {product} {command line, ergonomic}",268"intx Tier3BackedgeNotifyFreqLog = 12 {product} {command line, ergonomic}",269"intx Tier3CompileThreshold = 1500 {product} {command line, ergonomic}",270"intx Tier3InvocationThreshold = 150 {product} {command line, ergonomic}",271"intx Tier3InvokeNotifyFreqLog = 9 {product} {command line, ergonomic}",272"intx Tier3MinInvocationThreshold = 75 {product} {command line, ergonomic}",273"intx Tier4BackEdgeThreshold = 30000 {product} {command line, ergonomic}",274"intx Tier4CompileThreshold = 11250 {product} {command line, ergonomic}",275"intx Tier4InvocationThreshold = 3750 {product} {command line, ergonomic}",276"intx Tier4MinInvocationThreshold = 450 {product} {command line, ergonomic}",277"double CompileThresholdScaling = 0.750000 {product} {command line}"278},279{280"intx Tier0BackedgeNotifyFreqLog = 10 {product} {command line, ergonomic}",281"intx Tier0InvokeNotifyFreqLog = 7 {product} {command line, ergonomic}",282"intx Tier23InlineeNotifyFreqLog = 20 {product} {command line, ergonomic}",283"intx Tier2BackedgeNotifyFreqLog = 14 {product} {command line, ergonomic}",284"intx Tier2InvokeNotifyFreqLog = 11 {product} {command line, ergonomic}",285"intx Tier3BackEdgeThreshold = 75000 {product} {command line, ergonomic}",286"intx Tier3BackedgeNotifyFreqLog = 13 {product} {command line, ergonomic}",287"intx Tier3CompileThreshold = 2500 {product} {command line, ergonomic}",288"intx Tier3InvocationThreshold = 250 {product} {command line, ergonomic}",289"intx Tier3InvokeNotifyFreqLog = 10 {product} {command line, ergonomic}",290"intx Tier3MinInvocationThreshold = 125 {product} {command line, ergonomic}",291"intx Tier4BackEdgeThreshold = 50000 {product} {command line, ergonomic}",292"intx Tier4CompileThreshold = 18750 {product} {command line, ergonomic}",293"intx Tier4InvocationThreshold = 6250 {product} {command line, ergonomic}",294"intx Tier4MinInvocationThreshold = 750 {product} {command line, ergonomic}",295"double CompileThresholdScaling = 1.250000 {product} {command line}"296},297{298"intx Tier0BackedgeNotifyFreqLog = 11 {product} {command line, ergonomic}",299"intx Tier0InvokeNotifyFreqLog = 8 {product} {command line, ergonomic}",300"intx Tier23InlineeNotifyFreqLog = 21 {product} {command line, ergonomic}",301"intx Tier2BackedgeNotifyFreqLog = 15 {product} {command line, ergonomic}",302"intx Tier2InvokeNotifyFreqLog = 12 {product} {command line, ergonomic}",303"intx Tier3BackEdgeThreshold = 120000 {product} {command line, ergonomic}",304"intx Tier3BackedgeNotifyFreqLog = 14 {product} {command line, ergonomic}",305"intx Tier3CompileThreshold = 4000 {product} {command line, ergonomic}",306"intx Tier3InvocationThreshold = 400 {product} {command line, ergonomic}",307"intx Tier3InvokeNotifyFreqLog = 11 {product} {command line, ergonomic}",308"intx Tier3MinInvocationThreshold = 200 {product} {command line, ergonomic}",309"intx Tier4BackEdgeThreshold = 80000 {product} {command line, ergonomic}",310"intx Tier4CompileThreshold = 30000 {product} {command line, ergonomic}",311"intx Tier4InvocationThreshold = 10000 {product} {command line, ergonomic}",312"intx Tier4MinInvocationThreshold = 1200 {product} {command line, ergonomic}",313"double CompileThresholdScaling = 2.000000 {product} {command line}"314},315{316"intx Tier0BackedgeNotifyFreqLog = 10 {product} {command line}",317"intx Tier0InvokeNotifyFreqLog = 7 {product} {command line}",318"intx Tier23InlineeNotifyFreqLog = 20 {product} {command line}",319"intx Tier2BackedgeNotifyFreqLog = 14 {product} {command line}",320"intx Tier2InvokeNotifyFreqLog = 11 {product} {command line}",321"intx Tier3BackEdgeThreshold = 60000 {product} {command line}",322"intx Tier3BackedgeNotifyFreqLog = 13 {product} {command line}",323"intx Tier3CompileThreshold = 2000 {product} {command line}",324"intx Tier3InvocationThreshold = 200 {product} {command line}",325"intx Tier3InvokeNotifyFreqLog = 10 {product} {command line}",326"intx Tier3MinInvocationThreshold = 100 {product} {command line}",327"intx Tier4BackEdgeThreshold = 40000 {product} {command line}",328"intx Tier4CompileThreshold = 15000 {product} {command line}",329"intx Tier4InvocationThreshold = 5000 {product} {command line}",330"intx Tier4MinInvocationThreshold = 600 {product} {command line}",331"double CompileThresholdScaling = 0.000000 {product} {command line}",332"interpreted mode"333}334};335336private static void verifyValidOption(String[] arguments, String[] expected_outputs, boolean tiered) throws Exception {337ProcessBuilder pb;338OutputAnalyzer out;339340pb = ProcessTools.createJavaProcessBuilder(arguments);341out = new OutputAnalyzer(pb.start());342343try {344for (String expected_output : expected_outputs) {345out.shouldContain(expected_output);346}347out.shouldHaveExitValue(0);348} catch (RuntimeException e) {349// Check if tiered compilation is available in this JVM350// Version. Throw exception only if it is available.351if (!(tiered && out.getOutput().contains("-XX:+TieredCompilation not supported in this VM"))) {352throw new RuntimeException(e);353}354}355}356357public static void main(String[] args) throws Exception {358359if (NON_TIERED_ARGUMENTS.length != NON_TIERED_EXPECTED_OUTPUTS.length) {360throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in non-tiered mode of operation does not match.");361}362363if (TIERED_ARGUMENTS.length != TIERED_EXPECTED_OUTPUTS.length) {364throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in tiered mode of operation.");365}366367// Check if thresholds are scaled properly in non-tiered mode of operation368for (int i = 0; i < NON_TIERED_ARGUMENTS.length; i++) {369verifyValidOption(NON_TIERED_ARGUMENTS[i], NON_TIERED_EXPECTED_OUTPUTS[i], false);370}371372// Check if thresholds are scaled properly in tiered mode of operation373for (int i = 0; i < TIERED_ARGUMENTS.length; i++) {374verifyValidOption(TIERED_ARGUMENTS[i], TIERED_EXPECTED_OUTPUTS[i], true);375}376}377}378379380