Initially, the bug was discussed here: https://stackoverflow.com/questions/35264582/why-is-multithreading-slowing-down/35264813
The root cause is that if for some reason directly or indirectly the color transform object is shared across the threads it cannot be used for parallel color transformation because the method LCMSTransform.doTransform() is synchronized. This code seems to be created when the littlecms 1.x was used which was not thread-safe, but the latest version is thread safe (subject to bugs). I can check that by compiling lcms with #define CMS_NO_PTHREADS which will cause some of our tests fail here and there. To check that transform can be used across the threads I created two quite heavyweight tests which tests different color transformations using different threads. The fix moves the data for the native transform from the LCMSTransform object to the NativeTransform class just to simplify synchronization steps, so only one volatile read of "transform" is executed in the common path. Result for the testcase attached to SO: https://stackoverflow.com/a/35264713 |№ threads|Before the fix|After the fix| |-------------|-------------|-------------| |1 | 693 ms | 699 ms| |8 | 6641 ms| 873 ms| |30 |34069 ms|1034 ms| ------------- Commit messages: - Merge branch 'master' into JDK-8273972 - new test - the test and comments - Initial version JDK-8273972 Changes: https://git.openjdk.java.net/jdk/pull/5671/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5671&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8273972 Stats: 358 lines in 5 files changed: 317 ins; 25 del; 16 mod Patch: https://git.openjdk.java.net/jdk/pull/5671.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5671/head:pull/5671 PR: https://git.openjdk.java.net/jdk/pull/5671
