From: Lars Magne Ingebrigtsen <larsi@gnus.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-devel@gnu.org
Subject: Re: trunk r113947: * image.c: Fix animation cache signature memory leak.
Date: Mon, 19 Aug 2013 22:55:33 +0200 [thread overview]
Message-ID: <m3k3jho0xm.fsf@stories.gnus.org> (raw)
In-Reply-To: <m3mwodpigt.fsf@stories.gnus.org> (Lars Magne Ingebrigtsen's message of "Mon, 19 Aug 2013 21:51:30 +0200")
I think what might really help with the speed is doing more caching and
a better liveliness analysis. Or something.
First of all, every iteration we re-parse the "super-wand":
if (filename)
status = MagickReadImage (image_wand, filename);
else
{
filename_hint = imagemagick_filename_hint (img->spec, hint_buffer);
MagickSetFilename (image_wand, filename_hint);
status = MagickReadImageBlob (image_wand, contents, size);
}
If we stash that in the cache, too, then my guess would be that we'd see
a rather large speed-up. We'd have to have a way to compute an ID for
the data, though. I'd suggest just doing a sha256 or something over
contents and then perhaps using the same animation cache. It'd need
some tweaks, though, because we don't want to cache non-animation
images, and we don't know whether they are or not before we've parsed
it. :-)
The other thing is that imagemagick_compute_animated_image clones the
wand before putting it into the cache:
cache->wand = CloneMagickWand (composite_wand)
This is because imagemagick_load_image later destroys the wand, so we
need a copy. This could be avoided, of course, and my guess is that
this would also be a nice speed-up, because copying a wand must probably
entail copying the entire data.
If you could look at this, I think the ImageMagick animation could start
approaching the gif animation code speed-wise. At present, it's much
slower, especially on large images.
This is the code snippet I use to test:
(url-retrieve "http://cdn.arwrath.com/1/148330.gif"
(lambda (&rest ignore)
(search-forward "\n\n")
(let ((image (create-image
(buffer-substring (point) (point-max))
'imagemagick t)))
(pop-to-buffer "*image*")
(erase-buffer)
(delete-all-overlays)
(put-image image (point) "*")
(image-animate image nil 60))))
--
(domestic pets only, the antidote for overdose, milk.)
No Gnus T-Shirt for sale: http://ingebrigtsen.no/no.php
and http://lars.ingebrigtsen.no/2013/08/twenty-years-of-september.html
prev parent reply other threads:[~2013-08-19 20:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1VBJTG-0003rv-7A@vcs.savannah.gnu.org>
2013-08-19 15:22 ` trunk r113947: * image.c: Fix animation cache signature memory leak Lars Magne Ingebrigtsen
2013-08-19 16:16 ` Paul Eggert
2013-08-19 16:19 ` Lars Magne Ingebrigtsen
2013-08-19 16:24 ` Paul Eggert
2013-08-19 16:40 ` Lars Magne Ingebrigtsen
2013-08-19 16:56 ` Paul Eggert
2013-08-19 17:04 ` Lars Magne Ingebrigtsen
2013-08-19 19:46 ` Paul Eggert
2013-08-19 19:51 ` Lars Magne Ingebrigtsen
2013-08-19 20:52 ` Paul Eggert
2013-08-19 20:56 ` Lars Magne Ingebrigtsen
2013-08-19 20:55 ` Lars Magne Ingebrigtsen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3k3jho0xm.fsf@stories.gnus.org \
--to=larsi@gnus.org \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).