RFR: 8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations
Claes Redestad
redestad at openjdk.org
Mon May 20 20:55:30 UTC 2024
On Mon, 20 May 2024 10:52:27 GMT, Claes Redestad <redestad at openjdk.org> wrote:
> We can fold the call to `Objects.checkIndex` into the code generated in generateTypeSwitchSkeleton instead of doing so by filtering the MH argument. This loads 9 less classes (of which 8 generated LFs and Species classes) on a minimal test, while being neutral on a throughput sanity test:
>
>
> Name Cnt Base Error Test Error Unit Change
> SwitchSanity.switchSum 15 8,162 ± 0,117 8,152 ± 0,131 ns/op 1,00x (p = 0,800 )
> * = significant
> ```
>
> A few additional optimizations includes generating the switch method using the precise type (to avoid the need for an explicitCast adaptation), and moving some seldom used `findStatic` calls to a holder. All in all this means a reduction by 33-34M cycles to bootstrap a trivial switch expression on my M1.
To help evaluate and diagnose the startup overheads I added a `main` method to the provided `SwitchSanity` micro. This only runs a single invocation and is easy to run using your startup benchmarking script/tool of choice:
Name Cnt Base Error Test Error Unit Change
Perfstartup-JMH 20 75,000 ± 4,455 62,000 ± 6,042 ms/op 1,21x (p = 0,000*)
:.cycles 277393501,850 ± 4422757,249 253819501,350 ± 5482340,325 cycles 0,92x (p = 0,000*)
:.instructions 701618995,500 ± 3774721,992 622929549,250 ± 3634060,803 instructions 0,89x (p = 0,000*)
:.taskclock 82,000 ± 3,564 74,000 ± 4,365 ms 0,90x (p = 0,000*)
* = significant
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19307#issuecomment-2121179185
More information about the core-libs-dev
mailing list