Forcing a bit of house-cleaning (old news for most, probably)
2009.08.27 22:24 by Leo Antunes - 6 Comments[UPDATE: why does the internet insist in making my posts embarrassingly obsolete?]
I had seen this Firefox* SQLite VACUUM trick on Lifehacker, but hadn’t done anything about it. Now for some reason I decided to give it a spin, but manually, since the proposed method didn’t work and I had zero patience to try and debug Firefox’s inner black magic.
Regardless, this certainly breathed some new life in the old guy:
#!/bin/sh find ~/.mozilla/firefox/ -name *.sqlite | while read db; do sqlite3 $db VACUUM; done |
It’s no miracle, Firefox’s still a juggernaut, but it makes things sensibly snappier. No idea how long this will last, probably depends on the amount of INSERTS and DELETES that go on daily.
But I wonder why they don’t do that automatically. I thought they did and never bothered to check (still haven’t, to be completely honest). It might be to avoid a small hiccup while the VACUUM’s performed, but then again, so many people complain about Firefox being slower then molasses that I can hardly see the point.
Anyway, it’s easy to complain about other people’s work. Gotta keep reminding myself of the old “show me the code!” motto.
* Iceweasel, whatever…
The problem is there’s no convenient time to run the VACUUM. Can’t do it at startup — that would make startup even slower. Can’t do it at shutdown — the computer might be turning off. Can’t do it at some random time while the browser is running — even if the browser’s idle, we can’t predict when the user will start doing stuff again, and the UI would be unresponsive for the duration.
There’s a bunch of work going on right now to move all use of SQLite off the UI thread, which will eventually let us run VACUUM in an idle period, but we’re not there yet. However, if you’d care to try 3.6alpha1, that has a lot of these changes already; general use of the URL bar should be more responsive.
Reply
Nice to know there’s some work going on in that sense. The fact that the database code and the UI code reside on the same thread explains a lot of Firefox’s issues.
Do you know if there’s any roadmap regarding a full async UI? The official roadmap seems a bit outdated … :)
I wish I had time enough and braincells enough to contribute. Perhaps one day…
Reply
Heh, yeah, that roadmap is ancient. I don’t know any more current unified roadmap, but poking around on wiki.mozilla.org will reveal a lot of individual groups’ plans.
Startup performance is a major concern for the 3.6 release cycle.
Reply
I would suggest a slightly more advanced syntax that can be run in cronjob directly (if the database is locked, it should be safe):
find ~/.mozilla/firefox -name ‘*.sqlite’ -exec sqlite3 {} VACUUM \;
Reply
Yeah, that’s a lot simpler.
I must admit I have a personal dislike to find’s -exec syntax, so I instinctively avoid using it when the other option’s still readable, but yeah, it’s definitely simpler.
To my defence, the “while” form can also be used in a cronjob, but of course without the newlines. It just seems like a bit of a waste to do that regularly, particularly if you’re on a laptop whose disks could be spinned down, so in my system I just made a small wrapper for Firefox that performs the cleanup on startup.
Reply
Thank you!! Made a big difference for me on x86_64 running iceweasel 3.5.
Reply