<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>shaver &#187; hacking</title>
	<atom:link href="http://shaver.off.net/diary/tag/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://shaver.off.net/diary</link>
	<description>noise from signal</description>
	<lastBuildDate>Fri, 18 Nov 2011 02:15:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>I made a thing</title>
		<link>http://shaver.off.net/diary/2011/01/22/i-made-a-thing/</link>
		<comments>http://shaver.off.net/diary/2011/01/22/i-made-a-thing/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 21:53:29 +0000</pubDate>
		<dc:creator>shaver</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bugzilla]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[redis]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://shaver.off.net/diary/?p=4018</guid>
		<description><![CDATA[A while ago I made a prototype of a simple, high-performance keyword search for bugzilla, using python and Redis.  It was pretty promising, able to do all/any queries against the summaries of all open Firefox bugs in a handful of milliseconds.  The bugzilla maintainers decided to use the database&#8217;s full-text engine instead, but I was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=22353#c43">A while ago</a> I made a prototype of a simple, high-performance keyword search for bugzilla, using python and <a href="http://redis.io/">Redis</a>.  It was pretty promising, able to do all/any queries against the summaries of all open Firefox bugs in a handful of milliseconds.  The bugzilla maintainers decided to use the database&#8217;s full-text engine instead, but I was nonetheless pretty pleased with it. </p>

<p></p><p>A month or two ago, I started rewriting it it atop <a href="http://nodejs.org">node.js</a> and gave it a simple websocket-based interface.  (It took a while, due to <a href="http://shaver.off.net/diary/2011/01/15/or-bpd2-to-its-friends/">The Unpleasantness</a> rather than the difficulty of the task itself.)  It was blazingly fast, easily able to keep up with real-time matching of entered keywords. The queries on the server side were finished in a dozen milliseconds or less, and the remainder of my 200 millisecond request budget was spent on data transfer back to the client. I had to limit the returned result set to the most recent 100 items to keep the transfer time down. I will probably look at compression in JS to improve things there. (Some requests take as much as half a second if I get unlucky on the network and result-set size.)</p>
<p>Building the index takes about 20 seconds on its wimpy VM, though retrieving all the summaries from bugzilla takes a fair bit longer. (It currently indexes open bugs in Firefox, Fennec, Core, Toolkit, NSPR and NSS.) I could do that on a timer and have it be current within 10 minutes, but it would be pretty wasteful: the rate of relevant change is on the order of a few dozen each minute, and updating that many summaries is literally microseconds.</p>
<p>Enter <a href="http://pulse.mozilla.org/">Pulse</a>, Christian Legnitto&#8217;s mozilla-wide message broker.  Wired up to Pulse, my index is up to date cheaply every 5 minutes, and once we deploy the bugzilla extension, the index will be updated within fractions of a second.</p>
<p>To support non-websocket browsers, <a href="http://hacks.mozilla.org/2010/12/websockets-disabled-in-firefox-4/">which is currently all of them</a>, I switched to using <a href="http://socket.io/">socket.io</a> for the transport.  The flashsocket transport adds about 100 milliseconds to the round-trip, which is unfortunate but here we are.</p>
<p>In all, it&#8217;s about <a href="http://hg.mozilla.org/users/shaver_mozilla.com/bzsearch/">500 lines of JS</a> on the server side, plus another ~150 lines for the scripts that do the loading, and I think it&#8217;s a great example of what tools like pulse and the <a href="https://wiki.mozilla.org/Bugzilla:REST_API">Bugzilla REST API</a> are going to make possible in 2011.  It&#8217;s also an example of how holy-crikey excellent Node and Redis are together.</p>
<p>(There&#8217;s an installation running <a href="http://pulsar.off.net:8000/">here</a>, which might randomly break as I hack on it.)</p>
<p>Update, 2 minutes after posting:
<blockquote><code>23 Jan 00:16:00 - searching for sex
23 Jan 00:16:00 - undefined: search 1 -> 1 in 0/1 ms</code></blockquote>
Hi, Internet.</p>
]]></content:encoded>
			<wfw:commentRss>http://shaver.off.net/diary/2011/01/22/i-made-a-thing/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>another random bit of instrumentation</title>
		<link>http://shaver.off.net/diary/2007/10/15/another-random-bit-of-instrumentation/</link>
		<comments>http://shaver.off.net/diary/2007/10/15/another-random-bit-of-instrumentation/#comments</comments>
		<pubDate>Mon, 15 Oct 2007 19:29:23 +0000</pubDate>
		<dc:creator>shaver</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[patch]]></category>

		<guid isPermaLink="false">http://shaver.off.net/diary/2007/10/15/another-random-bit-of-instrumentation/</guid>
		<description><![CDATA[Last week, I was wondering about how the frame freelist/recycling/arena behaviour might impact dynamic memory footprint, especially for long-lived pages that do a lot of DOM-whacking. So in a few hours on Friday and today I whipped up an ugly, ugly patch that tracks the total outstanding &#8220;live&#8221; frame size for a given PresShell instance, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I was wondering about how the frame freelist/recycling/arena behaviour might impact dynamic memory footprint, especially for long-lived pages that do a lot of DOM-whacking.  So in a few hours on Friday and today I whipped up <a href="http://shaver.off.net/misc/presshell-stats-0.patch.txt">an ugly, ugly patch</a> that tracks the total outstanding &#8220;live&#8221; frame size for a given PresShell instance, and the total size of those that are being kept on the freelist.  I doubt I&#8217;ll have much time to do more with it, but it might be an interesting addition to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=392351">about:memory</a> when that gets rolling.  I&#8217;d also like to make the frame counting not be debug-only, and surface that information as well, just for kicks.</p>

<p><code>[  { uri: "resource://gre/res/hiddenWindow.html", allocated: 11768, onFreelist: 212 }, <br />
 { uri: "chrome://browser/content/browser.xul", allocated: 172775, onFreelist: 15064 }, <br />
 { uri: "http://www.mozilla.org/projects/minefield/", allocated: 88944, onFreelist: 1292 }, <br />
 { uri: "http://news.google.com/", allocated: 476528, onFreelist: 2368 }, <br />
 { uri: "http://dojotoolkit.org/demos/fisheye-demo", allocated: 102379, onFreelist: 39540 }, <br />
 { uri: "http://jquery.com/plugins/project/Plugins/category/48", allocated: 166888, onFreelist: 1320 }, <br />
 { uri: "http://jquery.com/plugins/project/LavaLamp", allocated: 91904, onFreelist: 1540 }, <br />
 { uri: "chrome://global/content/console.xul", allocated: 47232, onFreelist: 313408 }, <br />
 { uri: "about:blank", allocated: 11768, onFreelist: 212 }, <br />
 { uri: "about:presshell-stats", allocated: 13620, onFreelist: 212 }, <br />
 ]</code></p>
]]></content:encoded>
			<wfw:commentRss>http://shaver.off.net/diary/2007/10/15/another-random-bit-of-instrumentation/feed/</wfw:commentRss>
		<slash:comments>-4</slash:comments>
		</item>
	</channel>
</rss>

