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:45 UTC 2025
On Wed, 30 Apr 2025 19:40:51 GMT, Vladimir Kozlov <kvn 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?
Except when specified on command line with `-XX:CICompilerCount=n`.
Actually your changes does not take this flag into account.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24972#discussion_r2069336376
More information about the hotspot-compiler-dev
mailing list