RFR: 8366681: [leyden] Precompile more C1 code [v3]

Vladimir Ivanov vlivanov at openjdk.org
Thu Sep 4 19:23:01 UTC 2025


On Wed, 3 Sep 2025 16:59:46 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Looking at how code goes through AOT+JIT pipeline, I believe we have several issues in the way we include the methods for precompilation.
>> 
>> 1. AP4 code gets replaced by more efficient A4 code, which can then deopt. Once it does, we go back to the fully normal JIT pipeline, with C1 compiling, C2 compiling, etc. Training run currently does A2 versions only when there is a tier2/3 training data present. We can pessimistically assume that A4/AP4 method should have A2 method generated for the sake of quicker deopt.
>> 
>> 2. I suspect a similar thing, but rarer, happens with A4 -> ... -> T1 transition when compiler queues are overloaded. We can generate A1 method for this case.
>> 
>> 3. When training is done with default configuration, but at runtime we enable only C1, we summarily miss almost *all* AOT methods, because A1 methods are rarely generated with a normal tiered policy. Generating A1 methods always would be convenient for hybrid C2 AOT + C1 JIT modes as well.
>> 
>> Overall, I think generating more C1 methods even when C2 methods are present in training is beneficial, as we prepare the ground for whatever corner case happens at runtime. Benchmarks show this improves performance model quite a bit. 
>> 
>> Since we now look at methods at all different tiers when deciding to precompile, compile IDs are not working all that well. I have rewritten that to use counters and method sizes. This seems to work well in practice.
>> 
>> Additional testing:
>>  - [x] `javac` performance tests (see comments)
>>  - [x] Linux x86_64 server fastdebug, `runtime/cds`
>
> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - Merge branch 'premain' into JDK-8366681-precompile-more-c1
>  - Merge branch 'premain' into JDK-8366681-precompile-more-c1
>  - Fix

Interesting idea.

2 observations:

* There are already AP4 versions present in the AOT cache. Why can't they be used instead of A2 until T3 arrives?  

* There were some rare discrepancies in compilation behavior between training and production runs which lead to AOT-cache mismatches and trigger unnecessary JIT-compilations. While proposed change alleviates the symptoms, It's beneficial to fix the root cause.

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

PR Comment: https://git.openjdk.org/leyden/pull/93#issuecomment-3255259379


More information about the leyden-dev mailing list