Page 1 of 1

Limiting threads of ImageMagick - not getting limited

Posted: 2011-10-09T07:19:24-07:00
by ramontayag
I'm on a virtual machine, and according to [this document in the Cache Storage and Resource Requirements section (http://www.imagemagick.org/script/architecture.php), if you're on a VPS you should probably limit the threads to two. I am. But before making changes, I checked to see what my settings (via `identify -list resource`) were:

Code: Select all

    File        Area      Memory         Map        Disk  Thread        Time
    ------------------------------------------------------------------------
     768   2.0004GiB   1.5003GiB   4.0009GiB       16EiB       4   unlimited
I then placed this in ~/.magick/policy.xml:

Code: Select all

    <policymap>
      <policy domain="resource" name="time" value="60"/>
      <policy domain="resource" name="thread" value="2"/>
    </policymap>
Then I checked my settings:

Code: Select all

    File        Area      Memory         Map        Disk  Thread        Time
    ------------------------------------------------------------------------
     768   2.0004GiB   1.5003GiB   4.0009GiB       16EiB       4          60
Howcome the thread isn't getting modified? I just copied and pasted the settings.

Note, I also asked this at http://superuser.com/questions/343648/l ... ng-limited but haven't gotten an answer :)

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-10-09T07:59:45-07:00
by magick
We got the expected results when we limited the threads in ~/.magick/policy.xml. We're using ImageMagick 6.7.2-10. You can also try setting OMP_NUM_THREADS or MAGICK_THREADS environment variable.

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-10-12T08:44:04-07:00
by ramontayag
magick wrote:We got the expected results when we limited the threads in ~/.magick/policy.xml. We're using ImageMagick 6.7.2-10. You can also try setting OMP_NUM_THREADS or MAGICK_THREADS environment variable.
Sorry for my ignorance, but I can't seem to find any document that specifies where I should set these variables. I've searched on Google and skimmed through documents on imagemagick.org. Could you point me to the right direction?

Thanks

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-10-12T09:10:38-07:00
by magick
These are environment variables, setting depends on your shell. Bash for example,
  • export OMP_NUM_THREADS=2

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-10-17T01:46:58-07:00
by ramontayag
Thank you!

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-11-02T07:16:16-07:00
by ramontayag
Hmm.. when I have these settings:

Code: Select all

File         Area       Memory          Map         Disk    Thread         Time
-------------------------------------------------------------------------------
 768     2.1479GB    1.0002GiB    2.0004GiB    unlimited         1           60
But in htop I still found two convert processes: http://is.gd/TQxAb0

Did I understand the threads parameter wrongly? How do I limit the number of convert calls that exist at a time?

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-11-02T20:16:17-07:00
by anthony
Threads are not processes.

Each convert command has no knowledge of any other convert process that may be running on the system.
That is just the way UNIX and other computer system work, and is known as segmented architecture.

To limit the total number of convert command, you have to basically not run that many convert commands!
That requires some IPC communications between your launching applications.

Re: Limiting threads of ImageMagick - not getting limited

Posted: 2011-11-03T00:29:04-07:00
by ramontayag
You're absolutely right. I got confused after leaving this topic for several weeks. I'm back to my original problem then (which I thought limiting the threads would solve): http://serverfault.com/questions/313915 ... n-too-long

These commands are called but then they get stuck, and then just take up memory. Looks like I'll need to handle them manually.