Integrated: 8349858: Print compilation task before blocking compiler thread for shutdown
Aleksey Shipilev
shade at openjdk.org
Fri Feb 14 13:56:15 UTC 2025
On Wed, 12 Feb 2025 12:56:17 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> 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>
>
>
> Additional testing:
> - [x] Linux x86_64 server fastdebug, `all`
This pull request has now been integrated.
Changeset: 742e735d
Author: Aleksey Shipilev <shade at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/742e735d7f6c4ee9ca5a4d290c59d7d6ec1f7635
Stats: 14 lines in 1 file changed: 14 ins; 0 del; 0 mod
8349858: Print compilation task before blocking compiler thread for shutdown
Reviewed-by: kvn, chagedorn
-------------
PR: https://git.openjdk.org/jdk/pull/23586
More information about the hotspot-compiler-dev
mailing list