<?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>Shawn Wilsher &#187; performance</title>
	<atom:link href="http://shawnwilsher.com/archives/tag/performance/feed" rel="self" type="application/rss+xml" />
	<link>http://shawnwilsher.com</link>
	<description></description>
	<lastBuildDate>Mon, 26 Jul 2010 17:36:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Startup Time in the Wild</title>
		<link>http://shawnwilsher.com/archives/421</link>
		<comments>http://shawnwilsher.com/archives/421#comments</comments>
		<pubDate>Mon, 26 Jul 2010 17:31:14 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[places]]></category>
		<category><![CDATA[session restore]]></category>
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=421</guid>
		<description><![CDATA[Over the weekend I spent some serious time with my computer running a bunch of tests with standalone talos in 11 different situations. First, a disclaimer: these tests were only designed to give some insight on the areas we should focus on for the goal. Each of these tests was reproduced at least once before [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend I spent some serious time with my computer running a bunch of tests with <a href="https://wiki.mozilla.org/StandaloneTalos">standalone talos</a> in 11 different situations.  First, a disclaimer: these tests were only designed to give some insight on the areas we should focus on for <a href="https://wiki.mozilla.org/Firefox/Projects/2010Q3_Dirty_Startup_Reduction">the goal</a>.  Each of these tests was reproduced at least once before I moved onto the next one in order to make sure the numbers were stable.</p>
<h2>The Tests</h2>
<ul>
<li>Clean profile.  This is just the standard profile that we normally run Ts with on tinderbox.  This is basically used a baseline for best possible performance.</li>
<li>Dirty profile.  This is actually my daily profile, with eight tabs that will open through session restore during startup.  Because of how talos works, these tabs don&#8217;t all have to load for the number to be generated.  Even so, you&#8217;ll notice a substantial slowdown.  Sadly, I fear I modified the profile I was using in a bad way because I can no longer reproduce the numbers I got (but the numbers recorded were reproduced four times before I moved on to the rest of the tests initially).</li>
<li>Bookmarks toolbar disabled.  This is a variation on the dirty profile test that just disables the bookmarks toolbar.</li>
<li>No places.  This is a variation on the dirty profile test that removes places files from the profile.</li>
<li>No <code>sessionstore.js</code>.  This is a variation on the dirty profile test that removes <code>sessionstore.js</code> from the profile.  This has the side effect of also not making the eight tabs load at startup.</li>
<li>No urlclassifier.  This is a variation on the dirty profile test that removes the urlclassifier related files from the profile.</li>
<li>No <code>cookies.sqlite</code>.  This is a variation on the dirty profile test that removes <code>cookies.sqlite</code> from the profile.</li>
<li>No extensions.  This is a variation on the dirty profile test that removes all add-on manager bits in the profile.</li>
<li>No <code>formhistory.sqlite</code>.  This is a variation on the dirty profile test that removes <code>formhistory.sqlite</code> from the profile.</li>
<li>No <code>downloads.sqlite</code>.  This is a variation on the dirty profile test that removes <code>downloads.sqlite</code> from the profile.</li>
<li>No <code>content-prefs.sqlite</code>.  This is a variation on the ditry profile test that removes <code>content-prefs.sqlite</code> from the profile.</li>
</ul>
<h2>Results</h2>
<p>I&#8217;m going to let some graphs do the talking here.  The first shows the raw test run data (which isn&#8217;t terribly interesting).  The second compares the reported startup time for each test.  You will probably want to click to zoom in.</p>
<div align="center"><a href="http://shawnwilsher.com/wp-content/uploads/2010/07/startup-data.png"><img src="http://shawnwilsher.com/wp-content/uploads/2010/07/startup-data-300x196.png" alt="Data of the startup time runs" title="Startup Data" width="300" height="196" class="alignnone size-medium wp-image-428" /></a></div>
<p><br/></p>
<div align="center"><a href="http://shawnwilsher.com/wp-content/uploads/2010/07/startup-time.png"><img src="http://shawnwilsher.com/wp-content/uploads/2010/07/startup-time-300x196.png" alt="Startup time of the various tests" title="Startup Time" width="300" height="196" class="alignnone size-medium wp-image-429" /></a></div>
<h2>Conclusions</h2>
<p>It looks like the best wins that we can get are related to fixing session restore to not scale linearly with the number of tabs it is restoring, and reduce the startup time costs of loading places files and <code>cookies.sqlite</code>.  It should be noted that this test was not measuring the load time for each tab, so something like <a href="https://addons.mozilla.org/en-US/firefox/addon/67651/">BarTab</a> would not help in this case.  The other good news is that <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=572223" title="too much cookies.sqlite io">we already have work underway to make cookies.sqlite load time not hurt</a> us so much during startup.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/421/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Bugzilla Helper 0.2.0</title>
		<link>http://shawnwilsher.com/archives/350</link>
		<comments>http://shawnwilsher.com/archives/350#comments</comments>
		<pubDate>Thu, 05 Nov 2009 18:14:16 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[Bugzilla Helper]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[Thunderbird]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=350</guid>
		<description><![CDATA[I just uploaded Bugzilla Helper 0.2.0. This improves on the last release by making making the submission of comments an asynchronous operation. It also uses the activity manager in Thunderbird to track the process of the submission, and retry it if an error occurs. There are still some apparent issues with the REST API that [...]]]></description>
			<content:encoded><![CDATA[<p>I just uploaded Bugzilla Helper 0.2.0.  This improves on <a href="http://shawnwilsher.com/archives/332">the last release</a> by making making the submission of comments an asynchronous operation.  It also uses the activity manager in Thunderbird to track the process of the submission, and retry it if an error occurs.</p>
<p>There are still some apparent issues with the REST API that the add-on is using, and I&#8217;ll likely include some workaround in upcoming versions.  <a href="https://addons.mozilla.org/en-US/thunderbird/addon/45501">0.2.0 is available on addons.mozilla.org</a> and is a recommended upgrade.  Current users will have to update since sandboxed add-ons do not automatically update.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/350/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Swing and a Miss</title>
		<link>http://shawnwilsher.com/archives/305</link>
		<comments>http://shawnwilsher.com/archives/305#comments</comments>
		<pubDate>Wed, 02 Sep 2009 21:48:41 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[AutoComplete]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[location bar]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=305</guid>
		<description><![CDATA[When we landed the asynchronous location bar, some people started to see substantially slower results. This was alarming since it was supposed to end up speeding or staying the same for everyone. After some investigation, we realized that the AutoComplete code was doing something very dumb with asynchronous searches. The problem was that the code [...]]]></description>
			<content:encoded><![CDATA[<p>When we landed the <a href="http://shawnwilsher.com/archives/279">asynchronous location bar</a>, some people started to see substantially slower results.  This was alarming since it was supposed to end up speeding or staying the same for everyone.  After some investigation, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=509048">we realized that the AutoComplete code was doing something very dumb</a> with asynchronous searches.  The problem was that the code would not actually handle the user pressing the enter key until the next set of results came in.  Not only did this result in slower processing of the user&#8217;s selection, it also meant that weird race conditions would come up such as up opening a new tab, pasting a url in, press enter, and then switch tabs resulting in the reloading of the page that was just switched to.  In other words, epic fail all around.</p>
<p>Luckily, the fix was trivial.  Now we handle the enter keypress immediately when the user hits it, and not later.  Problem solved :)</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/305/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Session Restore Now Writes to Disk Off of the Main Thread</title>
		<link>http://shawnwilsher.com/archives/294</link>
		<comments>http://shawnwilsher.com/archives/294#comments</comments>
		<pubDate>Mon, 17 Aug 2009 19:47:28 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[fsync]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[session restore]]></category>
		<category><![CDATA[write]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=294</guid>
		<description><![CDATA[Last week I landed bug 485976 which moves the writing and subsequent fsync (or flush on windows) call to a background thread. This should benefit all of our users, especially those with slower hard drives. Paul O&#8217;Shannessey has filed another bug that will reduce the amount of disk activity substantially more that will benefit our [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I landed <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=485976" title="Move writing sessionstore.js off the main thread">bug 485976</a> which moves the writing and subsequent fsync (or flush on windows) call to a background thread.  This should benefit all of our users, especially those with slower hard drives.  <a href="http://zpao.com/">Paul O&#8217;Shannessey</a> has <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=508740" title="Use mozStorage for SessionStore">filed another bug</a> that will reduce the amount of disk activity substantially more that will benefit our users even more.</p>
<h3>Background</h3>
<p>Session restore writes out to disk very frequently &#8211; every ten seconds, in fact.  This behavior is controllable by the preference <a href="http://kb.mozillazine.org/Browser.sessionstore.interval"><code>browser.sessionstore.interval</code></a> for those who want to reduce that, but then you run the risk of not having all your data saved if you crash.  We really don&#8217;t want to reduce that time for our users.</p>
<p>The amount of data that is written out to disk by session restore scales linearly with the number of tabs and windows you have open.  The more you have, the more data has to be written out to disk, and the longer it is going to take.</p>
<p>As <a href="http://shawnwilsher.com/archives/168">we learned in the past with Places</a>, writing to disk and calling fsync can be painfully slow.  In session restore code, we are doing this very often <em>and</em> on the main thread.  Clearly, this is a bad thing.</p>
<h3>Process and Solution</h3>
<p>This section is a bit technical, so feel free to skip it. The short answer is “do not block the main thread while writing and flushing data to the hard drive.”</p>
<p>We wanted to address this problem as much as we could for Firefox 3.6.  In order to actually reduce the number of writes and fsync calls, we would have to heavily modify how session restore manages and writes its data.  That is a big change that we were not comfortable doing this late in the 3.6 cycle.  On top of that, we do not really have the manpower to do that change since the people who know that code well are working on other performance improvements for this release.  The simple solution for now then is to move our write and fsync calls off of the main thread.</p>
<p>Luckily, <a href="http://weblogs.mozillazine.org/bz/">Boris Zbarsky</a> had recently <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=482310" title=" Add an API to asynchronously copy data to an output stream">written a new API for JS consumers</a> to asynchronously copy an input stream to an output stream.  This API would work great for session restore!  We had to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=508605" title="NetUtil.asyncCopy does not handle nsISafeOutputStreams correctly">fix one minor issue with the underlying code</a> not properly handling nsISafeOutputStreams (which make sure we fsync properly), but once that was done, <a href="https://bugzilla.mozilla.org/attachment.cgi?id=393074&#038;action=diff">the fix</a> was incredibly simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/294/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Asynchronous Location Bar has Landed</title>
		<link>http://shawnwilsher.com/archives/279</link>
		<comments>http://shawnwilsher.com/archives/279#comments</comments>
		<pubDate>Tue, 11 Aug 2009 20:33:07 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[location bar]]></category>
		<category><![CDATA[mozStorage]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[places]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=279</guid>
		<description><![CDATA[About two weeks ago the asynchronous location bar work landed in mozilla-central without much issue. It&#8217;s also in the Firefox 3.6 alpha we just recently released. This has the potential to impact all of our users, but those on slower hard drives will notice this the most. Your location bar searches may not complete any [...]]]></description>
			<content:encoded><![CDATA[<p>About two weeks ago the asynchronous location bar work <a href="http://hg.mozilla.org/mozilla-central/pushloghtml?changeset=8cff4bd2121a">landed in mozilla-central</a> without much issue.  It&#8217;s also in the <a href="https://developer.mozilla.org/devnews/index.php/2009/08/07/firefox-3-6-alpha-1-now-available-for-download/">Firefox 3.6 alpha</a> we just recently released.  This has the potential to impact all of our users, but those on slower hard drives will notice this the most.  Your location bar searches may not complete any faster than before, but they certainly won&#8217;t be hanging your browser and locking up the UI.</p>
<h3>Background</h3>
<p>We&#8217;ve been getting reports for some time about the location bar hanging the application for some users when they are typing in it.  This wasn&#8217;t a problem that was reproducible on every machine, and even on machines that saw it, it wasn&#8217;t always 100% reproducible.  Clearly, this behavior is not desirable, so we set out to fix it.</p>
<p>I had a theory to the cause almost a year ago and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=455555">filed a bug</a> that I was hoping we could work on and fix for Firefox 3.5.  We knew that reading data off a disk can be slow (and certainly would complete in a non-deterministic amount of time).  Since SQLite uses blocking read calls (no more code can execute until the data is read from disk), this could certainly be the cause of the slowdown our users were seeing.  Some simple profiling showed that this was largely the cause of the hanging.  Work began on the project, but it was clear that enough issues were cropping up that we were not going to be able to safely take this change for Firefox 3.5, and resources were diverted elsewhere.</p>
<h3>Process and Solution</h3>
<p>This section is a bit technical, so feel free to skip it.  The short answer is &#8220;do not block the main thread while reading from the hard drive.&#8221;</p>
<p>In order to not block the main thread while reading from disk we either need to make SQLite use non-blocking read system calls, or call into SQLite off of the main thread.  Changing the SQLite code isn&#8217;t something we want to do, so that solution was out of the question.  Luckily, we had solved a similar problem with writes and fsyncs earlier in the Firefox 3.5 development with the <a href="http://shawnwilsher.com/archives/162">asynchronous Storage API</a>.</p>
<p>The first implementation that we tried essentially did the same thing that the old code did.  We would execute a query, but this time asynchronously, and then process the results and see if they match.  There were two issues with this approach, however.  The first issue was that we were filtering every history and bookmark entry on the main thread for a given search.  That could be a lot of work we end up doing, and with the additional overhead of moving data across threads, the common case would see no win.  The second issue was that once we selected a result in the location bar, and a search was not yet complete, there would be a hang as the main thread processed a bunch of events that Storage had posted to it containing results.</p>
<p>At this point, we realized we needed to do the filtering on a thread other than the main thread.  After some thought, we was figured that the easiest way to do that would be to use a SQL function that we define in the WHERE clause of our autocomplete queries.  This way, all the filtering is done on a background thread, and the code that runs on the main thread only deals with results we will actually use.  This solution exposed some things in the Storage backend like lock contention and a few other subtle issues, but nothing major came up.</p>
<p>For more details on how the location bar search results are generated, see <a href="http://stackoverflow.com/questions/540725/how-does-firefoxs-awesome-bar-match-strings/1208458#1208458">my explanation here</a>.</p>
<p>If you weren&#8217;t having a problem before, chances are you won&#8217;t notice any difference at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/279/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Asychronous Storage Statements Just Got Faster</title>
		<link>http://shawnwilsher.com/archives/275</link>
		<comments>http://shawnwilsher.com/archives/275#comments</comments>
		<pubDate>Tue, 04 Aug 2009 21:17:51 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[mozStorage]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=275</guid>
		<description><![CDATA[One of the complaints I received early on about the asynchronous storage API was that it wasn&#8217;t faster to call executeAsync compared to execute or executeStep on the calling thread. This was largely the case because people were testing the function call without any other IO going on, which isn&#8217;t going to always be the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the complaints I received early on about the asynchronous storage API was that it wasn&#8217;t faster to call <code>executeAsync</code> compared to <code>execute</code> or <code>executeStep</code> on the calling thread.  This was largely the case because people were testing the function call without any other IO going on, which isn&#8217;t going to always be the case for our users.  People tend to have more than one application running on their computer doing something, and that something can often hit the disk.  The culprit of the slowdown was recreating the sqlite3_stmt object for each call to <code>executeAsync</code>.</p>
<p>With my work on the asynchronous location bar, I wanted to speed up the call to <code>executeAsync</code> to make it as fast as possible so autocomplete look ups would be quick.  To accomplish this, we now cache the asynchronous <code>sqlite3_stmt</code> object so we don&#8217;t recreate it on every call to <code>executeAsync</code>.  This amortizes the cost that was causing the asynchronous API to be slower than the synchronous one.</p>
<p>This solution is not sufficient, however, if you bind parameters to the statement before calling <code>executeAsync</code>.  This is because binding parameters stores state on the underlying <code>sqlite3_stmt</code> object, and we can&#8217;t store that information on it because it could be in use on the background thread.  To get around this issue, I reuse a code from the <a href="http://shawnwilsher.com/archives/258">recent asynchronous storage API addition</a> to store the bound values in memory and then bind them at the time of execution on the background thread.  <a href="http://www.visophyte.org/blog/">Andrew Sutherland</a> and I were both very happy at how small this patched ended up being as a result of good API design in the past.</p>
<p>The bonus with this two step solution is that we&#8217;ve also completely removed the possibility of lock contention inside of the SQLite library on the calling thread of <code>executeAsync</code>.  If you have a long running <code>sqlite3_step</code> command on the background thread, this could block your call to one of the binding calls or <code>executeAsync</code>, which is undesirable.</p>
<p>This code is checked in on mozilla-central, and will be a part of Gecko 1.9.2.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/275/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Test Build: Asynchronous Location Bar (Take &gt;2)</title>
		<link>http://shawnwilsher.com/archives/270</link>
		<comments>http://shawnwilsher.com/archives/270#comments</comments>
		<pubDate>Sat, 11 Jul 2009 22:32:40 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[location bar]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[places]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=270</guid>
		<description><![CDATA[I have another test build for folks to try out. This fixes a possible error condition that could happen in certain circumstances. This build has two known issues: There is a lot of flickering when new results show up. This is being tracked in bug 393902. Your computer will hang for a period of time [...]]]></description>
			<content:encoded><![CDATA[<p>I have another test build for folks to try out.  This fixes a possible error condition that could happen in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=455555#c104">certain circumstances</a>.  This build has two known issues:</p>
<ol>
<li>There is a lot of flickering when new results show up.  This is being tracked in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=393902">bug 393902</a>.</li>
<li>Your computer will hang for a period of time (it will become responsive again) if you continue to type once no results are found.  This is being tracked in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=503701">bug 503701</a>.</li>
</ol>
<p>This is built off of a &#8220;stable&#8221; point of mozilla-central, so it&#8217;s like using a 3.6 nightly.  All the normal warnings apply about using it.  I&#8217;m told this greatly increases the speed at which results obtained by many people.  If you experience any issues (other than the two listed here), please let me know!  The <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-places/">builds can be found here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/270/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Build: Asynchronous Location Bar</title>
		<link>http://shawnwilsher.com/archives/266</link>
		<comments>http://shawnwilsher.com/archives/266#comments</comments>
		<pubDate>Thu, 09 Jul 2009 00:30:15 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[location bar]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[places]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=266</guid>
		<description><![CDATA[It&#8217;s been a while, but last week I started working on the asynchronous location bar patch again. The add-on from past posts will not be updated as there are binary changes that need to be made. I do, however, have some test builds that you can try out. These are built of off mozilla-central, so [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while, but last week I started working on the <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=455555">asynchronous location bar patch</a> again.  The <a href="http://shawnwilsher.com/archives/255">add-on from past posts</a> will not be updated as there are binary changes that need to be made.  I do, however, have some test builds that you can try out.  These are built of off mozilla-central, so it&#8217;s like using a 3.6 nightly.  That means it may not be stable, and you shouldn&#8217;t use this with your default profile (but feel free to copy your places.sqlite file into a new one to really hammer on it).  If you are interested in trying it out, the <a href="https://build.mozilla.org/tryserver-builds/sdwilsh@shawnwilsher.com-try-b70b9b91f7d7/">builds can be found here</a>.</p>
<p>Your feedback is appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/266/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Query Performance Monitoring</title>
		<link>http://shawnwilsher.com/archives/251</link>
		<comments>http://shawnwilsher.com/archives/251#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:22:49 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[mozStorage]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[places]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=251</guid>
		<description><![CDATA[Over in bug 481261 I am adding support in mozStorage to warn when a query doesn&#8217;t use an index to sort. This is a debug only warning that uses NS_WARNING to tell you what query is at fault, and the total number of sort operations that were used on it. Luckily, SQLite exposes a handy [...]]]></description>
			<content:encoded><![CDATA[<p>Over in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=481261" title="Expose when queries are being inefficient in debug builds">bug 481261</a> I am adding support in mozStorage to warn when a query doesn&#8217;t use an index to sort.  This is a debug only warning that uses <a href="https://developer.mozilla.org/En/NS_WARNING"><tt>NS_WARNING</tt></a> to tell you what query is at fault, and the total number of sort operations that were used on it.</p>
<p>Luckily, SQLite exposes a <a href="http://www.sqlite.org/c3ref/stmt_status.html">handy function</a> that tells us this information.  In general, you want to use a index in your <tt>ORDER BY</tt> clause so SQLite can use it to generate the order the results a given back.  If you do not use an index, SQLite has to first get all the results in memory, then it sorts them, and then it starts to return results.  If you expect a lot of results, this can get very expensive.</p>
<p>There were suggestions on the newsgroups to also add an API so debuggers such as <a href="http://getfirebug.com/releases/">ChromeBug</a> or <a href="https://addons.mozilla.org/en-US/firefox/addon/5817">SQLite Manager</a> could listen for these types of errors.  I&#8217;ll be filing follow-up bugs for some of these suggestions later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/251/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More fsync and write Reduction</title>
		<link>http://shawnwilsher.com/archives/242</link>
		<comments>http://shawnwilsher.com/archives/242#comments</comments>
		<pubDate>Tue, 03 Mar 2009 23:30:52 +0000</pubDate>
		<dc:creator>Shawn Wilsher</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[DTrace]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[fsync]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[places]]></category>
		<category><![CDATA[write]]></category>

		<guid isPermaLink="false">http://shawnwilsher.com/?p=242</guid>
		<description><![CDATA[As you may or may not be aware, my personal mission as of late is to reduce the number of writes and fsyncs that Firefox makes, and move the ones that we do have to make off of the main thread. The primary target here has been Places, and the work is still continuing. The [...]]]></description>
			<content:encoded><![CDATA[<p>As you may or may not be aware, my personal mission as of late is to reduce the number of writes and fsyncs that Firefox makes, and move the ones that we do have to make off of the main thread.  The primary target here has been Places, and the work is still continuing.</p>
<p>The Firefox team has been focusing on <a href="https://wiki.mozilla.org/Firefox3.1/Sprints">code sprints</a> to get some small well scoped things done for Firefox 3.1 since we&#8217;ve got a bit more time.  My <a href="https://wiki.mozilla.org/Firefox3.1/Sprints/Places_Expiration_Performance_Refactoring" title="Places Expiration Performance Refactoring">latest sprint</a> can be found over in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=480211" title="Stop expiring history on every page visit">bug 480211</a>, where I&#8217;ve removed a write and fsync that we used to do after every page visited.  If we had enough pages in history that were old enough, we would remove them from history.  We now do this off of the main thread, asynchronously at the same time we flush data from our temporary tables to our permanent ones.  The net result is the same number of writes and one less fsync.  Additionally, the write is no longer done on the main thread.</p>
<p>Sadly, I couldn&#8217;t measure any real-world performance gains with my <a href="http://shawnwilsher.com/archives/178">DTrace scripts</a> &#8211; in fact I saw no change during several different runs of Tp3 with various places.sqlite files.  It&#8217;s quite possible I did not have the conditions setup correctly to have pages expiring, and I could have spent a few more hours generating just the right places.sqlite file to demonstrate wins in the real world, but the theory behind the patch is pretty simple.  The gain is pretty obvious.</p>
<p>Just another drop in the bucket of performance wins for Firefox.  Stay tuned, as there is more to come!</p>
]]></content:encoded>
			<wfw:commentRss>http://shawnwilsher.com/archives/242/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
