Re: Performance slow down because of cache method change

Bob Friesenhahn <[email protected]> Thu, 31 Mar 2005 09:44:35 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
On Thu, 31 Mar 2005, Stefan v. Wachter wrote:

> Hello,
>
> Usings the C- API of GraphicsMagick 1.1.5 on windows (Win2000 or XP) we
> encountered a mysterious slow down after processing of some hundreds of
> frames. The performance goes down to about 40 percent of the initial
> value. The slow down - as far as I can see - does not occur on the
> Linux platform. There is no memory leak visible.
> With Bobs help I found out that the pixel cache method changes instantly from 
> memory cache to disk cache and this causes the slow down.
> But now I don't know why this happens and I don't understand how 
> GraphicsMagick decides which method it uses. Is there a way to force 
> GraphicsMagick to use allways memory cache?

Changing the pixel cache method was a *possible* reason for the 
slowdown, but as I expressed in email to you yesterday, this is the 
*actual* cause for the slowdown:

"
   In order to support writing the vectors as MVG ("Magick
   Vector Graphics", the MVG vector string is stored in an
   image attribute ("[MVG]"), which is extended as new
   vectors are drawn. This allows accumulating a complete
   drawing list as the user produces new drawing requests.
   After running for a long time, this string can get
   quite long and it is apparently repeatedly copied
   (probably due to realloc) and strlen is repeatedly used
   in order to determine its length. The memory
   consumption was actually growing over time. This should
   be happening under Linux as well, but it may be that
   Linux's realloc is more efficient.

   Using:

       DrawDestroyContext(drawContext);
       SetImageAttribute(theImage,"[MVG]",0); // <-- new line

   will purge the "[MVG]" attribute so that the next
   drawing iteration starts fresh. It seems that this
   elminates the performance problem.
"

With this minor change, the loops in your test program execute in 
constant time for me.

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


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30