I had posted this message on the main user board without any response. I'm hoping someone on this board may have an idea where to point me in the right direction.
I have a php page that processes a large text file and draws an image using ImageMagick. A long text command is generated and then exec(cmd) is used to do the drawing. It works like a charm, but recently the processing slowed to a crawl. This was following a new laptop, new mac operating system, different ImageMagick version and using macports to install ImageMagick rather than a manual install so I can't say what coincided with the problem appearing. After a while I tracked down the problem to any use of text fonts. A minimal example is shown in the following php script:
<?php
exec ("convert -list font");
?>
takes less that 0.5 seconds to run using the command line, but the same script run as a web page takes over 26 seconds.
The following script:
<?php
exec("convert -list");
?>
takes less than 0.02 seconds on the command line or on the web page.
Any use of draw or annotate suffers the same slowdown.
I presume that the system environment for apache differs from a command-line login environment as a specific user and that for some reason it is taking the call under php/apache for ever to locate available fonts. I've looked everywhere for a clue for how to setup the apache system environment and how my login environment differs from the apache environment but with no luck so far.
Any ideas?
Mac OSX 10.6.2,
macports
ImageMagick vesion 6.5.6-1_0
Built-in apache-2.0 server
Slow Font access under apache
Re: Slow Font access under apache
Add -debug all to your command line and it displays the time it takes to complete a task. You can get additional timing with -debug all,trace.
Re: Slow Font access under apache
Thanks for the pointer to -debug all/trace
All the time seems to be taken on loading the system fonts, not in finding the configuration files. Here is the fragment of the -debug all,trace output that spans the long delay
2010-01-03T23:13:25-05:00 0:01 0.010u 6.5.6 Trace convert[15160]: string.c/DestroyStringInfo/771/Trace ...
2010-01-03T23:13:25-05:00 0:01 0.010u 6.5.6 Trace convert[15160]: splay-tree.c/GetNumberOfNodesInSplayTree/964/Trace ...
2010-01-03T23:13:25-05:00 0:01 0.010u 6.5.6 Configure convert[15160]: type.c/LoadTypeList/985/Configure Loading type configure file "built-in" ...
2010-01-03T23:13:52-05:00 0:28 26.330u 6.5.6 Trace convert[15160]: utility.c/GetPathComponent/1179/Trace /Library/Fonts/Bradley Hand ITC TT-Bold
2010-01-03T23:13:52-05:00 0:28 26.330u 6.5.6 Trace convert[15160]: string.c/SubstituteString/2410/Trace ...
2010-01-03T23:13:52-05:00 0:28 26.330u 6.5.6 Trace convert[15160]: string.c/SubstituteString/2410/Trace ...
compared with running the same script via the command line
2010-01-04T11:01:29-05:00 0:01 0.010u 6.5.6 Trace convert[17470]: string.c/DestroyStringInfo/771/Trace ...
2010-01-04T11:01:29-05:00 0:01 0.010u 6.5.6 Trace convert[17470]: splay-tree.c/GetNumberOfNodesInSplayTree/964/Trace ...
2010-01-04T11:01:29-05:00 0:01 0.010u 6.5.6 Configure convert[17470]: type.c/LoadTypeList/985/Configure Loading type configure file "built-in" ...
2010-01-04T11:01:29-05:00 0:01 0.040u 6.5.6 Trace convert[17470]: utility.c/GetPathComponent/1179/Trace /Library/Fonts/Bradley Hand ITC TT-Bold
2010-01-04T11:01:29-05:00 0:01 0.040u 6.5.6 Trace convert[17470]: string.c/SubstituteString/2410/Trace ...
2010-01-04T11:01:29-05:00 0:01 0.040u 6.5.6 Trace convert[17470]: string.c/SubstituteString/2410/Trace ...
All the time seems to be taken on loading the system fonts, not in finding the configuration files. Here is the fragment of the -debug all,trace output that spans the long delay
2010-01-03T23:13:25-05:00 0:01 0.010u 6.5.6 Trace convert[15160]: string.c/DestroyStringInfo/771/Trace ...
2010-01-03T23:13:25-05:00 0:01 0.010u 6.5.6 Trace convert[15160]: splay-tree.c/GetNumberOfNodesInSplayTree/964/Trace ...
2010-01-03T23:13:25-05:00 0:01 0.010u 6.5.6 Configure convert[15160]: type.c/LoadTypeList/985/Configure Loading type configure file "built-in" ...
2010-01-03T23:13:52-05:00 0:28 26.330u 6.5.6 Trace convert[15160]: utility.c/GetPathComponent/1179/Trace /Library/Fonts/Bradley Hand ITC TT-Bold
2010-01-03T23:13:52-05:00 0:28 26.330u 6.5.6 Trace convert[15160]: string.c/SubstituteString/2410/Trace ...
2010-01-03T23:13:52-05:00 0:28 26.330u 6.5.6 Trace convert[15160]: string.c/SubstituteString/2410/Trace ...
compared with running the same script via the command line
2010-01-04T11:01:29-05:00 0:01 0.010u 6.5.6 Trace convert[17470]: string.c/DestroyStringInfo/771/Trace ...
2010-01-04T11:01:29-05:00 0:01 0.010u 6.5.6 Trace convert[17470]: splay-tree.c/GetNumberOfNodesInSplayTree/964/Trace ...
2010-01-04T11:01:29-05:00 0:01 0.010u 6.5.6 Configure convert[17470]: type.c/LoadTypeList/985/Configure Loading type configure file "built-in" ...
2010-01-04T11:01:29-05:00 0:01 0.040u 6.5.6 Trace convert[17470]: utility.c/GetPathComponent/1179/Trace /Library/Fonts/Bradley Hand ITC TT-Bold
2010-01-04T11:01:29-05:00 0:01 0.040u 6.5.6 Trace convert[17470]: string.c/SubstituteString/2410/Trace ...
2010-01-04T11:01:29-05:00 0:01 0.040u 6.5.6 Trace convert[17470]: string.c/SubstituteString/2410/Trace ...
Re: Slow Font access under apache
Any resolution to this issue? I'm experiencing the same thing under MAMP.
Re: Slow Font access under apache
Note that specifying the source font file provides no improvement (i.e. -font MyLocalFontFile.ttf rather than -font Arial-Bold)
Re: Slow Font access under apache
The issue only occurs when I have Apache configured to start on system startup (using MAMP). If I start Apache manually after my system has booted or restart Apache at any point the issue does not occur.