src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/BootstrapWatchDog.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/BootstrapWatchDog.java	Mon Mar 20 17:38:27 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/BootstrapWatchDog.java	Mon Mar 20 17:38:27 2017

*** 21,41 **** --- 21,42 ---- * questions. */ package org.graalvm.compiler.hotspot; import static org.graalvm.compiler.hotspot.HotSpotGraalCompiler.fmt; ! import static org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.GRAAL_OPTION_PROPERTY_PREFIX; ! import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import org.graalvm.compiler.debug.TTY; import org.graalvm.compiler.options.Option; + import org.graalvm.compiler.options.OptionKey; import org.graalvm.compiler.options.OptionType; ! import org.graalvm.compiler.options.OptionValues; import jdk.vm.ci.code.CompilationRequest; /** * A watch dog that monitors the duration and compilation rate during a
*** 56,68 **** --- 57,69 ---- public static class Options { // @formatter:off @Option(help = "Ratio of the maximum compilation rate below which the bootstrap compilation rate must not fall " + "(0 or less disables monitoring).", type = OptionType.Debug) ! public static final OptionValue<Double> BootstrapWatchDogCriticalRateRatio = new OptionValue<>(0.25D); ! public static final OptionKey<Double> BootstrapWatchDogCriticalRateRatio = new OptionKey<>(0.25D); @Option(help = "Maximum time in minutes to spend bootstrapping (0 to disable this limit).", type = OptionType.Debug) ! public static final OptionValue<Double> BootstrapTimeout = new OptionValue<>(15D); ! public static final OptionKey<Double> BootstrapTimeout = new OptionKey<>(15D); // @formatter:on } /** * Count of completed compilations. This is updated by the compiler threads and read by the
*** 86,102 **** --- 87,108 ---- * Creates and returns a {@link BootstrapWatchDog} if * {@link Options#BootstrapWatchDogCriticalRateRatio} is not set to 0 otherwise returns * {@code null}. */ static BootstrapWatchDog maybeCreate(HotSpotGraalRuntimeProvider graalRuntime) { ! return MAX_RATE_DECREASE <= 0.0D && TIMEOUT == 0 ? null : new BootstrapWatchDog(graalRuntime); ! OptionValues options = graalRuntime.getOptions(); + int timeout = (int) (Options.BootstrapTimeout.getValue(options) * 60); + double maxRateDecrease = Options.BootstrapWatchDogCriticalRateRatio.getValue(options); + return maxRateDecrease <= 0.0D && timeout == 0 ? null : new BootstrapWatchDog(graalRuntime, timeout, maxRateDecrease); } ! private BootstrapWatchDog(HotSpotGraalRuntimeProvider graalRuntime, int timeout, double maxRateDecrease) { this.setName(getClass().getSimpleName()); this.start(); this.graalRuntime = graalRuntime; + this.timeout = timeout; + this.maxRateDecrease = maxRateDecrease; } /** * Set to true to debug the watch dog. */
*** 113,129 **** --- 119,135 ---- private static final long EPOCH = 5; /** * Time in seconds before stopping a bootstrap. */ ! private static final int TIMEOUT = (int) (Options.BootstrapTimeout.getValue() * 60); ! private final int timeout; /** * The watch dog {@link #hitCriticalCompilationRateOrTimeout() hits} a critical compilation rate * if the current compilation rate falls below this ratio of the maximum compilation rate. */ ! private static final double MAX_RATE_DECREASE = Options.BootstrapWatchDogCriticalRateRatio.getValue(); ! private final double maxRateDecrease; @Override public void run() { if (DEBUG) { TTY.printf("%nStarted %s%n", this);
*** 140,159 **** --- 146,165 ---- if (DEBUG) { TTY.printf("%.2f: compilation rate is %.2f/sec%n", seconds(elapsed), rate); } if (rate > maxRate) { maxRate = rate; ! } else if (rate < (maxRate * MAX_RATE_DECREASE)) { ! } else if (rate < (maxRate * maxRateDecrease)) { TTY.printf("%nAfter %.2f seconds bootstrapping, compilation rate is %.2f compilations per second " + ! "which is below %.2f times the max compilation rate of %.2f%n", seconds(elapsed), rate, MAX_RATE_DECREASE, maxRate); ! "which is below %.2f times the max compilation rate of %.2f%n", seconds(elapsed), rate, maxRateDecrease, maxRate); TTY.printf("To enable monitoring of long running individual compilations, re-run with -D%s%s=%.2f%n", GRAAL_OPTION_PROPERTY_PREFIX, CompilationWatchDog.Options.CompilationWatchDogStartDelay.getName(), seconds(elapsed) - 5); hitCriticalRateOrTimeout = true; return; } ! if (elapsed > TIMEOUT * 1000) { ! if (elapsed > timeout * 1000) { if (requestsAtTimeout == null) { requestsAtTimeout = snapshotRequests(); stacksAtTimeout = new HashMap<>(); for (Thread t : requestsAtTimeout.keySet()) { stacksAtTimeout.put(t, t.getStackTrace());
*** 203,213 **** --- 209,219 ---- private static double seconds(long ms) { return (double) ms / 1000; } /** ! * Queries whether a critically low compilation rate or {@link #TIMEOUT} occurred. ! * Queries whether a critically low compilation rate or {@link #timeout} occurred. */ boolean hitCriticalCompilationRateOrTimeout() { return hitCriticalRateOrTimeout; }

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/BootstrapWatchDog.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File