<?xml version="1.0" encoding="UTF-8"?>
<article>
  <blurb>It's a simple fix, but it makes a difference.</blurb>
  <blurb-html>&lt;p&gt;It&amp;#8217;s a simple fix, but it makes a difference.&lt;/p&gt;</blurb-html>
  <body>When I first wrote the new storage module for the Password Manager, I took a few "shortcuts," trying to keep my code DRY. Partially this was because of the first patch by Mrinal Kant, but mostly it was because I like to reuse code. This bit us just a bit.

I mentioned in my "first post about this change":http://zpao.com/articles/10-passwordmgr_storage that we were initially considerably slower in the critical &lt;code&gt;countLogins&lt;/code&gt; method. While it got improved before being checked in, it was still marginally slower (milliseconds on an abnormally large dataset).

As I said before, this was most likely since we were doing a &lt;code&gt;SELECT *&lt;/code&gt; on the &lt;code&gt;moz_logins&lt;/code&gt; table, and looping over the results and counting. This allowed me to reuse more code. Loops are a kind of slow, and since this was so important, I decided to speed it up.

"I filed a bug":https://bugzilla.mozilla.org/show_bug.cgi?id=451479 just over a week ago entitled "storage-mozStorage should use COUNT in countLogins" - which pretty much explains what the solution to the above problem. I created a patch which essentially just switched the mosStorage module to use &lt;code&gt;SELECT COUNT(1)&lt;/code&gt;. I reran the performance tests I created and we're doing much better now. There's still a miniscule loss in speed from the legacy storage module, but at this point, we've done all that we can, and where the difference was milliseconds, its closer to millisecond.

This was "checked in":http://hg.mozilla.org/mozilla-central/rev/ce557eb9ef4a today (thanks Justin!).

And that's it. I have another patch in the pipeline and hopefully I'll have time to get it finished, approved, and reviewed for the freeze (whenever that is now).</body>
  <body-html>&lt;p&gt;When I first wrote the new storage module for the Password Manager, I took a few &amp;#8220;shortcuts,&amp;#8221; trying to keep my code &lt;span class="caps"&gt;DRY&lt;/span&gt;. Partially this was because of the first patch by Mrinal Kant, but mostly it was because I like to reuse code. This bit us just a bit.&lt;/p&gt;


	&lt;p&gt;I mentioned in my &lt;a href="http://zpao.com/articles/10-passwordmgr_storage"&gt;first post about this change&lt;/a&gt; that we were initially considerably slower in the critical &lt;code&gt;countLogins&lt;/code&gt; method. While it got improved before being checked in, it was still marginally slower (milliseconds on an abnormally large dataset).&lt;/p&gt;


	&lt;p&gt;As I said before, this was most likely since we were doing a &lt;code&gt;SELECT *&lt;/code&gt; on the &lt;code&gt;moz_logins&lt;/code&gt; table, and looping over the results and counting. This allowed me to reuse more code. Loops are a kind of slow, and since this was so important, I decided to speed it up.&lt;/p&gt;


	&lt;p&gt;&lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=451479"&gt;I filed a bug&lt;/a&gt; just over a week ago entitled &amp;#8220;storage-mozStorage should use &lt;span class="caps"&gt;COUNT&lt;/span&gt; in countLogins&amp;#8221; &amp;#8211; which pretty much explains what the solution to the above problem. I created a patch which essentially just switched the mosStorage module to use &lt;code&gt;SELECT COUNT(1)&lt;/code&gt;. I reran the performance tests I created and we&amp;#8217;re doing much better now. There&amp;#8217;s still a miniscule loss in speed from the legacy storage module, but at this point, we&amp;#8217;ve done all that we can, and where the difference was milliseconds, its closer to millisecond.&lt;/p&gt;


	&lt;p&gt;This was &lt;a href="http://hg.mozilla.org/mozilla-central/rev/ce557eb9ef4a"&gt;checked in&lt;/a&gt; today (thanks Justin!).&lt;/p&gt;


	&lt;p&gt;And that&amp;#8217;s it. I have another patch in the pipeline and hopefully I&amp;#8217;ll have time to get it finished, approved, and reviewed for the freeze (whenever that is now).&lt;/p&gt;</body-html>
  <created-at type="datetime">2008-08-28T17:23:17-07:00</created-at>
  <id type="integer">11</id>
  <permalink>passwordmgr_storage_faster</permalink>
  <published type="boolean">true</published>
  <published-at type="datetime">2008-08-28T21:00:00-07:00</published-at>
  <title>Making the New Password Manager Storage Faster</title>
  <updated-at type="datetime">2008-08-28T18:01:47-07:00</updated-at>
</article>
