On Fri, 14 Feb 2025 17:11:16 GMT, Bernd <d...@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