<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Gecko&#8217;s new image cache</title>
	<atom:link href="http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/</link>
	<description>\o/</description>
	<lastBuildDate>Fri, 21 Dec 2012 19:03:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Andrew Gaul</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-34</link>
		<dc:creator>Andrew Gaul</dc:creator>
		<pubDate>Tue, 31 Mar 2009 01:24:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-34</guid>
		<description><![CDATA[Measure twice, cut once.  ;-)]]></description>
		<content:encoded><![CDATA[<p>Measure twice, cut once.  <img src='http://blog.mozilla.org/joe/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JOEDREW!</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-33</link>
		<dc:creator>JOEDREW!</dc:creator>
		<pubDate>Tue, 31 Mar 2009 00:58:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-33</guid>
		<description><![CDATA[I admit that I haven&#039;t benchmarked this at all, but there is honestly no reason to - image cache manipulation went from the #1 hotspot to not even in the profile for a Tp run when I changed to dirty bits from always updating.

(One problem is that we can get lots of &quot;change key&quot; notifications in a row as an image incrementally downloads and decodes. This is a lot of useless churn. I suppose I could combine both push/pop and dirty bits, but as I said, it&#039;s not a hotspot at all.)]]></description>
		<content:encoded><![CDATA[<p>I admit that I haven&#8217;t benchmarked this at all, but there is honestly no reason to &#8211; image cache manipulation went from the #1 hotspot to not even in the profile for a Tp run when I changed to dirty bits from always updating.</p>
<p>(One problem is that we can get lots of &#8220;change key&#8221; notifications in a row as an image incrementally downloads and decodes. This is a lot of useless churn. I suppose I could combine both push/pop and dirty bits, but as I said, it&#8217;s not a hotspot at all.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gaul</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-32</link>
		<dc:creator>Andrew Gaul</dc:creator>
		<pubDate>Tue, 31 Mar 2009 00:51:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-32</guid>
		<description><![CDATA[Joedrew wrote:
&gt; And doing even O(log(n)) work on each of these elements
&gt; (small n at any one time, but large churn) was, in my
&gt; mind, a non-starter.

Let&#039;s ignore esoteric heaps and concentrate on STL heaps.  I don&#039;t understand the use case well enough, but many O(log n) may beat a few O(n) even for small n.  Probably best to benchmark push_heap and pop_heap instead of guessing.  O(log n) may be faster than you think!]]></description>
		<content:encoded><![CDATA[<p>Joedrew wrote:<br />
&gt; And doing even O(log(n)) work on each of these elements<br />
&gt; (small n at any one time, but large churn) was, in my<br />
&gt; mind, a non-starter.</p>
<p>Let&#8217;s ignore esoteric heaps and concentrate on STL heaps.  I don&#8217;t understand the use case well enough, but many O(log n) may beat a few O(n) even for small n.  Probably best to benchmark push_heap and pop_heap instead of guessing.  O(log n) may be faster than you think!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JOEDREW!</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-31</link>
		<dc:creator>JOEDREW!</dc:creator>
		<pubDate>Tue, 31 Mar 2009 00:23:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-31</guid>
		<description><![CDATA[n is small, on the order of a couple hundred elements at the most (5 MB cap on the heap&#039;s contents). There were two problems that I saw: at at least one point, I was convinced that I needed access to both decrease_key _and_ increase_key - which isn&#039;t available in most heaps, and isn&#039;t implemented on Mozilla&#039;s target platforms&#039; STLs as far as I can tell.

The second problem was that Fibonacci heap, as I saw it, didn&#039;t support increase_key in an O(1) way. And doing even O(log(n)) work on each of these elements (small n at any one time, but large churn) was, in my mind, a non-starter.

And, when it came to choosing between implementing a heap on my own and just trying lazy updating, _of course_ I chose the latter. :)]]></description>
		<content:encoded><![CDATA[<p>n is small, on the order of a couple hundred elements at the most (5 MB cap on the heap&#8217;s contents). There were two problems that I saw: at at least one point, I was convinced that I needed access to both decrease_key _and_ increase_key &#8211; which isn&#8217;t available in most heaps, and isn&#8217;t implemented on Mozilla&#8217;s target platforms&#8217; STLs as far as I can tell.</p>
<p>The second problem was that Fibonacci heap, as I saw it, didn&#8217;t support increase_key in an O(1) way. And doing even O(log(n)) work on each of these elements (small n at any one time, but large churn) was, in my mind, a non-starter.</p>
<p>And, when it came to choosing between implementing a heap on my own and just trying lazy updating, _of course_ I chose the latter. <img src='http://blog.mozilla.org/joe/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gaul</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-30</link>
		<dc:creator>Andrew Gaul</dc:creator>
		<pubDate>Mon, 30 Mar 2009 22:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-30</guid>
		<description><![CDATA[pop_heap, decrease_key, then push_heap is still O(log n), compared with make_heap of O(n).  I agree that esoteric heaps may have better run-times.  Do you need to change multiple weights at once?  How big is n?]]></description>
		<content:encoded><![CDATA[<p>pop_heap, decrease_key, then push_heap is still O(log n), compared with make_heap of O(n).  I agree that esoteric heaps may have better run-times.  Do you need to change multiple weights at once?  How big is n?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JOEDREW!</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-29</link>
		<dc:creator>JOEDREW!</dc:creator>
		<pubDate>Mon, 30 Mar 2009 21:48:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-29</guid>
		<description><![CDATA[Yes, that&#039;s the whole point! I worded this poorly.

Whenever I removed an element, though, through Cancel() or other reasons, or - and this is much more important - an element&#039;s weight got changed, either because it got another cache hit, or we loaded more information from the network, we had to heapify all over again. Heapification is O(N).

Fibonacci heaps have an O(1) &#124;decrease key&#124; operation, but unfortunately that doesn&#039;t map directly to the changes that happen while images are loading and being used.]]></description>
		<content:encoded><![CDATA[<p>Yes, that&#8217;s the whole point! I worded this poorly.</p>
<p>Whenever I removed an element, though, through Cancel() or other reasons, or &#8211; and this is much more important &#8211; an element&#8217;s weight got changed, either because it got another cache hit, or we loaded more information from the network, we had to heapify all over again. Heapification is O(N).</p>
<p>Fibonacci heaps have an O(1) |decrease key| operation, but unfortunately that doesn&#8217;t map directly to the changes that happen while images are loading and being used.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Gaul</title>
		<link>http://blog.mozilla.org/joe/2009/03/30/geckos-new-image-cache/#comment-28</link>
		<dc:creator>Andrew Gaul</dc:creator>
		<pubDate>Mon, 30 Mar 2009 21:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.org/joe/?p=18#comment-28</guid>
		<description><![CDATA[Joedrew wrote:
&gt; The main problem is that updating the heap implemented
&gt; in the STL (I believe a binary heap) is an O(n)
&gt; operation.

Are you sure?  push_heap and pop_heap should be O(log n):

http://www.cppreference.com/wiki/stl/algorithm/push_heap]]></description>
		<content:encoded><![CDATA[<p>Joedrew wrote:<br />
&gt; The main problem is that updating the heap implemented<br />
&gt; in the STL (I believe a binary heap) is an O(n)<br />
&gt; operation.</p>
<p>Are you sure?  push_heap and pop_heap should be O(log n):</p>
<p><a href="http://www.cppreference.com/wiki/stl/algorithm/push_heap" rel="nofollow">http://www.cppreference.com/wiki/stl/algorithm/push_heap</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
