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 pull request has now been integrated. Changeset: e49e5b5a Author: Sergey Bylokhov <[email protected]> URL: https://git.openjdk.java.net/jdk/commit/e49e5b5a7ed9e493380fb73100057898c707b31b Stats: 358 lines in 5 files changed: 317 ins; 25 del; 16 mod 8273972: Multi-core choke point in CMM engine (LCMSTransform.doTransform) Reviewed-by: prr ------------- PR: https://git.openjdk.java.net/jdk/pull/5671
