Re: Issue with GM through JNI

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Wed, 19 Jul 2017, Tianyu Lang wrote:

> Hi Bob,
>
> The DSETJMP_IS_THREAD_SAFE build flag solved the performance problem with
> libpng. However, we found out libjpeg also suffers from the same slowness
> caused by locking.
>
> We dug a little and found this line in jpeg.c:
> entry=SetMagickInfo("JPEG");
> entry->thread_support=False; /* libjpeg is not thread safe */
>
> I did some research and according to here
> <https://www.imagemagick.org/discourse-server/viewtopic.php?t=25495>, it
> seems like libjpeg is thread safe as long as only one thread works on one
> jpeg object. In that case, I am thinking if I can change the thread_support
> to True to allow GM to output multiple JPEGs concurrently.
>
> Or is there any other caveats?

The issue with JPEG is the same as for PNG.  The JPEG coder also uses 
setjmp/longjmp for error recovery.  Is is unfortunate that it does not 
use the same preprocessor definition as PNG does.

Make sure to test with multiple threads under JNI, including with 
corrupt files which might cause an error return (based on longjmp()) 
in the reader.  You should discover pretty quickly if there is a 
problem.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.