RFR: 8347606: Optimize Java implementation of ML-DSA

Chen Liang liach at openjdk.org
Sun Feb 16 15:44:10 UTC 2025


On Fri, 14 Feb 2025 17:11:16 GMT, Bernd <duke at openjdk.org> wrote:

>> It turns out that initializing a multidimensional array with `int[][] a = new int[rows][cols]` is slower than allocating each column in a loop. Since we do a lot of large multidimensional array allocations in ML-DSA, the optimized initialization improves performance by roughly 10%.
>
> src/java.base/share/classes/sun/security/provider/ML_DSA.java line 1237:
> 
>> 1235:         return res;
>> 1236:     }
>> 1237: 
> 
> Centralizing the allocation into a helper on its own Looks unseful (for resource Management, debugging/profiling and to pick the optimal implementation).
> 
> but it’s a shame that 2 dimensional allocations are sub-optimal, shouldnt that be addressed in the jvm (or c2?)

Indeed, it's better if hotspot can recognize and optimize the bytecode sequence generated by javac, or javac should generate bytecode like these methods to speed up allocation in general.

Is splitting the allocation into a dedicated method a factor? I know this may affect JIT compilation heuristics.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23642#discussion_r1957355167


More information about the security-dev mailing list