On Fri, 24 Sep 2021 04:38:13 GMT, Sergey Bylokhov <[email protected]> wrote:

> 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|

This looks OK but I want to submit a test job to make sure no nasty surprises

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

PR: https://git.openjdk.java.net/jdk/pull/5671

Reply via email to