JDK-8283807 : Handle CompileThreshold the same as other thresholds when scaled with -XX:CompileThresholdScaling
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-03-28
  • Updated: 2022-05-17
  • Resolved: 2022-05-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b22Fixed
Related Reports
Blocks :  
Blocks :  
Description
The valid range of CompileThresholdScaling is set to the following:

  product(double, CompileThresholdScaling, 1.0,                             \
          "Factor to control when first compilation happens "               \
          "(both with and without tiered compilation): "                    \
          "values greater than 1.0 delay counter overflow, "                \
          "values between 0 and 1.0 rush counter overflow, "                \
          "value of 1.0 leaves compilation thresholds unchanged "           \
          "value of 0.0 is equivalent to -Xint. "                           \
          ""                                                                \
          "Flag can be set as per-method option. "                          \
          "If a value is specified for a method, compilation thresholds "   \
          "for that method are scaled by both the value of the global flag "\
          "and the value of the per-method flag.")                          \
          range(0.0, DBL_MAX)                                               \
                             
However, if DBL_MAX is used, the VM fails to start after JDK-8283013

CompileThresholdScaling scales several compiler thresholds. If the scaled threshold value is outside of the allowed range, the default value is kept. 
When CompileThreshold is outside the allowed range, the VM is not created: change CompileThreshold to be handled by CompileThresholdScaling like the other thresholds.

$ java -XX:+PrintFlagsRanges --version | grep CompileThresholdScaling
   double CompileThresholdScaling                            [ 0.000                     ... 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000 ]                           {product} {default}


$ java -XX:CompileThresholdScaling=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000 --version
intx Tier0InvokeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier0BackedgeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier3InvocationThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier3MinInvocationThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier3CompileThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier3BackEdgeThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier2InvokeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier2BackedgeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier3InvokeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier3BackedgeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier23InlineeNotifyFreqLog=32 is outside the allowed range [ 0 ... 30 ]
intx Tier4InvocationThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier4MinInvocationThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier4CompileThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
intx Tier4BackEdgeThreshold=9223372036854775807 is outside the allowed range [ 0 ... 2147483647 ]
OnStackReplacePercentage cannot be validated because CompileThreshold value is invalid
CompileThreshold (9223372036854775807) must be between 0 and 1073741823
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Comments
Changeset: dd06cc63 Author: Tobias Holenstein <tobias.holenstein@oracle.com> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2022-05-06 07:08:19 +0000 URL: https://git.openjdk.java.net/jdk/commit/dd06cc638ec54e54cce599f82f37eb56abac2eae
06-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8501 Date: 2022-05-02 13:17:49 +0000
02-05-2022

-XX:CompileThresholdScaling=1073741824 is the first value that could not create the VM. The reason is that CompileThresholdScaling scales CompileThreshold which has default value 1 and max. value 1073741823. OnStackReplacePercentage then checks if CompileThreshold is outside its allowed range and stops VM creation when the range is not met. But setting the max. allowed value of CompileThreshold to 1073741823 would not fix the problem since it just scales CompileThreshold. As soon as CompileThreshold is set manually e.g. -XX:CompileThreshold=2 with CompileThresholdScaling=1073741823 the VM would again fail to be created. CompileThresholdScaling also scaled 15 other thresholds where the VM just prints a warning if the scaled value is too large and then keeps the current value. So I suggest it makes more sense to just do the same for CompileThreshold: Just print a warning "CompileThreshold is outside the allowed range [ 0 ... 1073741823 ]" and keep the default value instead of stopping VM creation
02-05-2022

ILW = can't set flag to unusual values, test failure; 1 test; no workaround = MLH = P4
28-03-2022

Because of this bug, the following test needs to be disabled after JDK-8283013 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java @@ -127,7 +127,10 @@ public class DoubleJVMOption extends JVMOption { validValues.add(formatValue(min)); } if (testMaxRange) { - validValues.add(formatValue(max)); + if (!name.equals("CompileThresholdScaling")) { + validValues.add(formatValue(max)); + } }
28-03-2022