Very slow conversion of large PSD on RHEL5
Posted: 2009-12-04T12:32:46-07:00
It just took 3 hours and 3 minutes to convert a 17460x5220 590Mb PSD to JPEG on a 32-bit RHEL5 server with 4 CPUs and 8Gb RAM. This server also has Apache and MySQL, and performance of those was suffering quite a bit during this convert process (which was triggered by a CLI PHP script). The resident memory was tapped out at 2Gb and it was using swap for part of the process, which no doubt was mainly responsible for the terrible performance, but I don't understand why it took so much memory as to need swap space. Can someone help me understand better how ImageMagick allocates memory for conversions?
The convert command used these options:
nice convert -limit map 1536mb -limit memory 1536mb -colorspace RGB -scale 10000x10000> -scale 1000x1000< -quality 85 -define registry:temporary-path=/opt/lightbox/magick theInputFile.psd theOutputFile.jpg
OS: RHEL5 32-bit
IM: 6.4.9-10 Q16
gs: 8.64
input format: PSD
WxH: 17460x5220
bytes: 590Mb
I'm curious why the "top" command showed 2.1Gb of resident memory when I set the memory limit to 1536mb. Does it add the 590Mb image size in bytes to the pixel cache size to arrive at 2.1Gb? I'm also curious why it is 2.1Gb instead of 2.0Gb when a 32-bit process can only address 2Gb of memory. But regardless, why does it need that much memory? Doesn't it take 4 bytes to store each pixel in the pixel cache (or does Q16 require 8 bytes per pixel?) For 17460x5220 pixels, that's either 348Mb at 4 bytes per pixel or 695Mb. And the output image is being constrained to a maximum of 10000 pixels in either direction, so it will take even less memory to store the output pixel cache. Why is this running out of memory and causing swapping, with the resulting horrible performance? Suggestions for improving this? I think we're going to switch to 64-bit RHEL and more RAM, but the numbers don't add up to me; the current environment ought to be able to handle this better.
The convert command used these options:
nice convert -limit map 1536mb -limit memory 1536mb -colorspace RGB -scale 10000x10000> -scale 1000x1000< -quality 85 -define registry:temporary-path=/opt/lightbox/magick theInputFile.psd theOutputFile.jpg
OS: RHEL5 32-bit
IM: 6.4.9-10 Q16
gs: 8.64
input format: PSD
WxH: 17460x5220
bytes: 590Mb
I'm curious why the "top" command showed 2.1Gb of resident memory when I set the memory limit to 1536mb. Does it add the 590Mb image size in bytes to the pixel cache size to arrive at 2.1Gb? I'm also curious why it is 2.1Gb instead of 2.0Gb when a 32-bit process can only address 2Gb of memory. But regardless, why does it need that much memory? Doesn't it take 4 bytes to store each pixel in the pixel cache (or does Q16 require 8 bytes per pixel?) For 17460x5220 pixels, that's either 348Mb at 4 bytes per pixel or 695Mb. And the output image is being constrained to a maximum of 10000 pixels in either direction, so it will take even less memory to store the output pixel cache. Why is this running out of memory and causing swapping, with the resulting horrible performance? Suggestions for improving this? I think we're going to switch to 64-bit RHEL and more RAM, but the numbers don't add up to me; the current environment ought to be able to handle this better.