RFR: 8348556: Inlining fails earlier for MemorySegment::reinterpret [v6]

Per Minborg pminborg at openjdk.org
Tue Apr 8 12:16:17 UTC 2025


On Tue, 8 Apr 2025 11:33:54 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> This PR proposes to add some `@ForceInline` annotations in the `Module` class in order to assist inlining of FFM var/method handles.
>> 
>> There are also some changes in other classes which, if implemented, can take us three additional levels of inlining. I drew a line there. There is a tradeoff with adding `@ForceInline` and just trying to get as deep as possible for a specific use case is probably not the best idea. 
>> 
>> I have opted not to inline the `j.l.Object` constructor in anticipation of broad impact. This currently sets the depth limit for this use case.
>> 
>> Tested and passed tier1-3
>
> Per Minborg 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 nine additional commits since the last revision:
> 
>  - Revert copyright year
>  - Revert changes to Object
>  - Merge branch 'master' into module-force-inline
>  - Add more @ForceInline and a benchmark
>  - Remove reformatting
>  - Remove file
>  - Revert change
>  - Rename method and variable
>  - Add @ForceInline annotations and restructure some methods

Baseline:

Benchmark                            (offsetCount)  (segmentSize)   Mode  Cnt        Score       Error  Units
FFMVarHandleInlineTest.t0_reference           2048           1024  thrpt   25  1552613.262 ? 14295.035  ops/s
FFMVarHandleInlineTest.t1_level8              2048           1024  thrpt   25  1558465.228 ?  8458.874  ops/s
FFMVarHandleInlineTest.t2_level9              2048           1024  thrpt   25  1542009.100 ? 10240.173  ops/s
FFMVarHandleInlineTest.t3_level10             2048           1024  thrpt   25  1553407.503 ? 10834.133  ops/s
FFMVarHandleInlineTest.t4_level11             2048           1024  thrpt   25    87666.558 ?   765.848  ops/s. <-- We hit the inline limit here


Patch without `Object` changes:

Benchmark                         (offsetCount)  (segmentSize)   Mode  Cnt      Score      Error  Units
FFMVarHandleInlineTest.t_level13           2048           1024  thrpt    6  72071.657 ± 1245.304  ops/s
FFMVarHandleInlineTest.t_level14           2048           1024  thrpt    6  69263.088 ± 2196.423  ops/s
FFMVarHandleInlineTest.t_level15           2048           1024  thrpt    6   3446.827 ±  118.659  **ops/s**


Patch with `Object` changes:

Benchmark                         (offsetCount)  (segmentSize)   Mode  Cnt       Score      Error  Units
FFMVarHandleInlineTest.t_level11           2048           1024  thrpt    6  1545991.924 ± 21206.450  ops/s
FFMVarHandleInlineTest.t_level12           2048           1024  thrpt    6  1542234.193 ± 18002.511  ops/s
FFMVarHandleInlineTest.t_level13           2048           1024  thrpt    6  1542601.822 ± 15041.864  ops/s
FFMVarHandleInlineTest.t_level14           2048           1024  thrpt    6   179053.325 ±  2496.002  ops/s
FFMVarHandleInlineTest.t_level15           2048           1024  thrpt    6     3433.861 ±   165.847  ops/s

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

PR Comment: https://git.openjdk.org/jdk/pull/23460#issuecomment-2786236800


More information about the core-libs-dev mailing list