RFR: 8356000: C1/C2-only modes use 2 compiler threads on 1 CPU machine

Vladimir Kozlov kvn at openjdk.org
Wed Apr 30 19:45:44 UTC 2025


On Wed, 30 Apr 2025 19:00:23 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> There is an unfortunate limitation with default tiered policy that we would have at least 2 threads on 1 CPU machine: 1 thread for C1, and 1 thread for C2.
> 
> But if we select C1-only or C2-only modes, we _also_ get 2 compiler threads, for which we have no good reason. These threads would just step on each other toes.
> 
> 
> $ build/linux-x86_64-server-release/images/jdk/bin/java -XX:-TieredCompilation -XX:ActiveProcessorCount=1 -XX:+PrintFlagsFinal 2>&1 | grep CICompilerCount
>      intx CICompilerCount = 2 {product} {ergonomic}
>      bool CICompilerCountPerCPU = true {product} {default}
> 
> $ build/linux-x86_64-server-release/images/jdk/bin/java -XX:TieredStopAtLevel=1 -XX:ActiveProcessorCount=1 -XX:+PrintFlagsFinal 2>&1 | grep CICompilerCount
>      intx CICompilerCount = 2 {product} {ergonomic}
>      bool CICompilerCountPerCPU = true {product} {default}
> 
> 
> It is a minor bug in `CompilationPolicy::initialize`, but it gets in the way studying Leyden in tight CPU scenarios. 
> 
> Additional testing:
>  - [x] New regression test passes with the fix, fails without it
>  - [ ] GHA

src/hotspot/share/compiler/compilationPolicy.cpp line 471:

> 469:         count = MAX2(max_count, min_count);
> 470:       }
> 471:       assert((!c1_only && !c2_only) || count <= active_cpus, "Too many threads: %d", count);

Should it be the general rule: don't create more compiler threads than available cpus?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24972#discussion_r2069334176


More information about the hotspot-compiler-dev mailing list