|
38 | 38 | import java.io.IOException;
|
39 | 39 | import java.io.OutputStream;
|
40 | 40 | import java.io.PrintStream;
|
| 41 | +import java.io.PrintWriter; |
| 42 | +import java.io.StringWriter; |
41 | 43 | import java.util.Formatter;
|
42 | 44 | import java.util.Map;
|
43 | 45 | import java.util.concurrent.TimeUnit;
|
@@ -436,6 +438,9 @@ private void maybeExitVM(ExceptionAction action) {
|
436 | 438 | private static final long COMPILATION_FAILURE_DETECTION_PERIOD_NS = TimeUnit.SECONDS.toNanos(2);
|
437 | 439 | private static final int MIN_COMPILATIONS_FOR_FAILURE_DETECTION = 25;
|
438 | 440 |
|
| 441 | + // Ensures the system compilation failure warning is printed once per VM process. |
| 442 | + private static final GlobalAtomicLong SYSTEMIC_COMPILATION_FAILURE_WARNED = new GlobalAtomicLong("SYSTEMIC_COMPILATION_FAILURE_WARNED", 0L); |
| 443 | + |
439 | 444 | /**
|
440 | 445 | * Gets the start of the current compilation period, initializing it to {@code initialValue} if
|
441 | 446 | * this is the first period.
|
@@ -487,17 +492,23 @@ private static boolean detectCompilationFailureRateTooHigh(OptionValues options,
|
487 | 492 | // Wait for period to expire or some minimum amount of compilations
|
488 | 493 | // before detecting systemic failure.
|
489 | 494 | if (rate > maxRate && (periodExpired || total > MIN_COMPILATIONS_FOR_FAILURE_DETECTION)) {
|
490 |
| - Formatter msg = new Formatter(); |
491 |
| - String option = GraalCompilerOptions.SystemicCompilationFailureRate.getName(); |
492 |
| - msg.format("Warning: Systemic Graal compilation failure detected: %d of %d (%d%%) of compilations failed during last %d ms [max rate set by %s is %d%%]. ", |
493 |
| - failed, total, rate, TimeUnit.NANOSECONDS.toMillis(periodNS), option, maxRateValue); |
494 |
| - msg.format("To mitigate systemic compilation failure detection, set %s to a higher value. ", option); |
495 |
| - msg.format("To disable systemic compilation failure detection, set %s to 0. ", option); |
496 |
| - msg.format("To get more information on compilation failures, set %s to Print or Diagnose. ", GraalCompilerOptions.CompilationFailureAction.getName()); |
497 |
| - TTY.println(msg.toString()); |
498 |
| - if (maxRateValue < 0) { |
499 |
| - // A negative value means the VM should be exited |
500 |
| - return true; |
| 495 | + if (SYSTEMIC_COMPILATION_FAILURE_WARNED.compareAndSet(0L, 1L)) { |
| 496 | + Formatter msg = new Formatter(); |
| 497 | + String option = GraalCompilerOptions.SystemicCompilationFailureRate.getName(); |
| 498 | + msg.format("Warning: Systemic Graal compilation failure detected: %d of %d (%d%%) of compilations failed during last %d ms [max rate set by %s is %d%%]. ", |
| 499 | + failed, total, rate, TimeUnit.NANOSECONDS.toMillis(periodNS), option, maxRateValue); |
| 500 | + msg.format("To mitigate systemic compilation failure detection, set %s to a higher value. ", option); |
| 501 | + msg.format("To disable systemic compilation failure detection, set %s to 0. ", option); |
| 502 | + msg.format("To get more information on compilation failures, set %s to Print or Diagnose. ", GraalCompilerOptions.CompilationFailureAction.getName()); |
| 503 | + StringWriter sw = new StringWriter(); |
| 504 | + cause.printStackTrace(new PrintWriter(sw)); |
| 505 | + msg.format("Current failure: %s", sw.toString().replace("\n", "\\n").replace("\t", "\\t")); |
| 506 | + TTY.println(msg.toString()); |
| 507 | + |
| 508 | + if (maxRateValue < 0) { |
| 509 | + // A negative value means the VM should be exited |
| 510 | + return true; |
| 511 | + } |
501 | 512 | }
|
502 | 513 | periodExpired = true;
|
503 | 514 | }
|
|
0 commit comments