On Thu, 16 Oct 2025 09:29:48 GMT, Sergey Bylokhov <[email protected]> wrote:
> The LCMS JNI code currently uses GetByteArrayElements, GetShortArrayElements, > GetIntArrayElements. These can be replaced by GetPrimitiveArrayCritical, > which avoids unnecessary copying of array data and provides measurable > performance improvements. > > This optimization was postponed earlier due to several reasons: > > - At that time, G1 did not support pinning, so critical sections could > interfere with GC (see [JEP 423](https://openjdk.org/jeps/423)). Also note > that this API is already used safely in many parts of java2d/awt. > - There was a plan to migrate to panama, but cold-startup issues > ([JDK-8313344](https://bugs.openjdk.org/browse/JDK-8313344)) remain > unresolved. > - GetPrimitiveArrayCritical forbids many JNI operations inside the critical > region, including allocations and java callbacks, which could be unsafe for > LCMS error handlers. However, LCMS color conversions do not trigger such > callbacks (see [LittleCMS > #516](https://github.com/mm2/Little-CMS/issues/516)). > > Performance data of various > [combinations](https://bugs.openjdk.org/secure/attachment/114273/OnePixelConvert-1.java) > for ColorSpace.toXX/fromXX in single-threaded and multi-threaded (64 > threads) modes: > https://jmh.morethan.io/?gists=b1440355577dc48f2b19b976b67f1120,d31c6a585330c9167b462e377445ad2f > Example: > <img width="1448" height="158" alt="image" > src="https://github.com/user-attachments/assets/57c98739-8007-43cc-8d87-b50a8bf2aec1" > /> Marked as reviewed by psadhukhan (Reviewer). ------------- PR Review: https://git.openjdk.org/jdk/pull/27841#pullrequestreview-3486325398
