RFR: 8349858: Print compilation task before blocking compiler thread for shutdown

Aleksey Shipilev shade at openjdk.org
Wed Feb 12 13:02:09 UTC 2025


JIT compilers in current Hotspot are compiling the code while being in native state. So if there is a running compilation, it does not block shutdown naturally. The shutdown code has cooperative mechanism to coordinate shutdown of compiler threads. Shutdown code sets the `CompilerBroker::should_block`, and compilers are regularly checking it with `CompilerBroker::maybe_block`. When shutdown is pending, the running compiler threads would eventually hit that `maybe_block`, block at transition to VM state, and that would allow shutdown to proceed.

One of the problems with this mechanism is observability: if compiler thread was running a long-running compilation, nothing would be written in the compilation logs about it. The compilation would just -- poof! -- disappear without a trace. This is arguably against the user expectation: we print _something_ whether the compilation succeeded or failed.

This kind of shutdown-during-heavy-compilation regularly happens in short runs in Leyden benchmarks. It made me scratch my head for quite a while before I understood where the compilation task went. I would like to add some sort of diagnostics for these cases.

Example `-XX:+PrintCompilation` output in Leyden after the patch (includes richer compile-task timings):


...
    430    W3.4    Q2.7    C0.3   4397               com.sun.tools.javac.comp.Check::checkProfile (40 bytes)
    447    W0.0    Q0.0   C10.3   4398               java.util.StringJoiner::toString (53 bytes)
    456    W0.0   Q10.4    C9.7   4399               java.lang.System$1::join (11 bytes)
Generated source code for 51 classes and compiled them in 403 ms (1 iterations)
    476   W36.6   Q11.6   C72.1   4393               com.sun.tools.javac.jvm.PoolWriter$WriteablePoolHelper::writeConstant (843 bytes)   blocked
    481    W0.0    Q0.0  C157.6   4390               com.sun.tools.javac.comp.TransTypes::visitIdent (129 bytes)   blocked
<end of log>

-------------

Commit messages:
 - Fix

Changes: https://git.openjdk.org/jdk/pull/23586/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23586&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8349858
  Stats: 14 lines in 1 file changed: 14 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/23586.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23586/head:pull/23586

PR: https://git.openjdk.org/jdk/pull/23586


More information about the hotspot-compiler-dev mailing list