GraphicsMagick - libxml2 linked with ICU causes slow-down

Bob Friesenhahn <[email protected]> Mon, 22 Apr 2019 10:37:50 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.announce
Message-ID <[email protected]>
It has been discovered that when libxml2 is linked with the ICU 
libraries (http://userguide.icu-project.org/) by enabling --with-icu 
in its configure options, that this will severely penalize the 
start-up time of any program which links with libxml2.  The ICU 
libraries are apparently written in C++, and are huge (e.g. 30MB).

Debian and Ubuntu are among the distributions which enable ICU support 
in libxml2 and this is likely common since some major applications 
need it.

Testing shows that for a static or shared-library build of 
GraphicsMagick, a trivial 'gm convert' command will execute 60% 
slower.  This impacts the single-shot performance when executing the 
utility on small files.

A remedy for this problem (if ICU can not be avoided) is to use a 
modules-based build ('--enable-shared' '--with-modules') since then 
libxml2 is not linked directly to 'gm' and the performance overhead is 
only incurred if libxml2 needs to be used (e.g. for SVG).

The performance impact due to simply linking with the ICU library was 
tested using the /bin/true program and using the LD_PRELOAD option to 
link libicuuc.so.60.2 with it.

This is the time to run /bin/true 1000 times:

real    0m0.669s
user    0m0.478s
sys     0m0.245s

and this is the time to run /bin/true 1000 times with libicuuc.so.60.2 
preloaded (LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libicuuc.so.60.2 
/bin/true):

real    0m1.734s
user    0m1.244s
sys     0m0.536s

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt