<?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>Smörgåsbord &#187; firefox</title>
	<atom:link href="http://smorgasbord.gavagai.nl/tags/firefox/feed/" rel="self" type="application/rss+xml" />
	<link>http://smorgasbord.gavagai.nl</link>
	<description>Ambachtelijk bereide beschouwingen.</description>
	<lastBuildDate>Fri, 06 Jan 2012 21:30:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>how I fixed my Firefox hiccups</title>
		<link>http://smorgasbord.gavagai.nl/2009/05/how-i-fixed-my-firefox-hiccups/</link>
		<comments>http://smorgasbord.gavagai.nl/2009/05/how-i-fixed-my-firefox-hiccups/#comments</comments>
		<pubDate>Thu, 07 May 2009 17:59:39 +0000</pubDate>
		<dc:creator>Wicher</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[inotify]]></category>
		<category><![CDATA[tmpfs]]></category>

		<guid isPermaLink="false">http://smorgasbord.gavagai.nl/?p=373</guid>
		<description><![CDATA[The other day I compiled Firefox 3.5-beta4, and, apart from many improvements, I noticed that I am now affected by the infamous &#8216;hiccups&#8217;. Firefox will stall for seconds at a time on my poor netbook. Details on how this relates to the many fsync() calls made by the persistance layer (SQLite) can be found all [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I compiled Firefox 3.5-beta4, and, apart from many improvements, I noticed that I am now affected by the infamous &#8216;hiccups&#8217;. Firefox will stall for seconds at a time on my poor netbook. Details on how this relates to the many fsync() calls made by the persistance layer (SQLite) can be found all over the net.<br />
But I don&#8217;t want Firefox to stall and I don&#8217;t want to keep my harddisk awake with all these writes when I&#8217;m on battery power.<br />
Luckily, both these problems go away if you put your Firefox profile on a ramdisk. There are numerous guides out there that save you from working out the details; I used <a href="http://forums.gentoo.org/viewtopic-t-717117.html">this one from the Gentoo forums</a>.<br />
The guide uses cron to sync the (presumably) modified contents of the ramdisk &#8211; bookmarks, cookies, whatever &#8211; back to permanent storage (harddisk). You and I both know that while it&#8217;s often convenient to use cron, it&#8217;s not always the Right Way of Doing Things®. Why sync if nothing&#8217;s changed? I wrote a script that employs the inotify system to do the syncing only when necessary. You&#8217;ll find it in the forum thread I linked to earlier, but I post it here &#8220;ter lering ende vermaeck&#8221;. Depending on your browser there might be a vertical scrollbar at the bottom which lets you read up to the EOL&#8217;s ;-)<br />
You can find the latest version at <a href="http://smormedia.gavagai.nl/dist/">my public repo</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Packfox, a tool to facilitate running Firefox with its profile stored</span>
<span style="color: #666666; font-style: italic;"># in RAM (tmpfs). Copyright 2008-2009 Wicher Minnaard, wicher@gavagai.eu .</span>
<span style="color: #666666; font-style: italic;"># Distributed under the WTFPL, http://smormedia.gavagai.nl/dist/packfox/COPYING</span>
<span style="color: #666666; font-style: italic;"># Latest version available at http://smormedia.gavagai.nl/dist/packfox/</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Change this to match your profile</span>
<span style="color: #007800;">PROFILE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">PFDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/.mozilla/firefox&quot;</span>
<span style="color: #666666; font-style: italic;"># Tar every .. seconds (regardless of changes)</span>
<span style="color: #007800;">TMOUT</span>=<span style="color: #ff0000;">&quot;1800&quot;</span>
<span style="color: #666666; font-style: italic;"># But not more often than every .. seconds (regardless of changes)</span>
<span style="color: #007800;">TMMIN</span>=<span style="color: #ff0000;">&quot;60&quot;</span>
<span style="color: #666666; font-style: italic;"># Regex for which files not to act on when they're changed.</span>
<span style="color: #666666; font-style: italic;"># Use inotifywait -m -e modify -e move -e create -e delete --exclude '(/Cache/)' -r your_profile_dir</span>
<span style="color: #666666; font-style: italic;"># and watch the output while browsing to determine which regex will be right for YOU.</span>
<span style="color: #007800;">IEXCL</span>=<span style="color: #ff0000;">&quot;(.sqlite-journal$)|(\-log.txt$)|(cookies.sqlite$)|(sessionstore\-[0-9].js$)|(/weave/)|(/Cache/)&quot;</span>
<span style="color: #666666; font-style: italic;"># Have you read everything and have you made the necessary adjustments? Then remove the line below ;-)</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;I should read the README and adjust the script variables before running this.&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># No user servicable parts below this line.</span>
<span style="color: #007800;">TGT</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Global vars</span>
<span style="color: #007800;">INOTYPID</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #007800;">SLEEPPID</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #007800;">PACKLOCK</span>=<span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Cleanup function</span>
terminate<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #666666; font-style: italic;"># If we are the daemon and we get SIGINTed/SIGTERMed, kill our children</span>
  <span style="color: #666666; font-style: italic;"># and if not already packing, do one last round of packing.</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(basename ${0})</span>&quot;</span> == <span style="color: #ff0000;">&quot;packfox-daemon&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
  <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${INOTYPID}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #800000;">${INOTYPID}</span>; <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SLEEPPID}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #800000;">${SLEEPPID}</span>; <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PACKLOCK}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span> packup; <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># For cleaning up </span>
<span style="color: #7a0874; font-weight: bold;">trap</span> terminate SIGINT SIGTERM
&nbsp;
<span style="color: #666666; font-style: italic;"># Suicide with goodbye note. If gxmessage is installed, use that.</span>
seppuku<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
  <span style="color: #c20cb9; font-weight: bold;">which</span> gxmessage <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> gxmessage <span style="color: #660033;">-nofocus</span> <span style="color: #660033;">-title</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(basename ${0})</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> xmessage <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1}</span>&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Checks and setup</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> seppuku <span style="color: #ff0000;">&quot;Profile dir doesn't exist&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(mount -t tmpfs | grep -F &quot;${TGT}&quot; )</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> seppuku <span style="color: #ff0000;">&quot;Mounting of profile's tmpfs failed. Check /etc/fstab and the output of 'dmesg'.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TGT}</span>/.unpacked&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xpf</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>.packed.tar&quot;</span> <span style="color: #660033;">-C</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>&quot;</span> \
<span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${TGT}</span>/.unpacked&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> seppuku <span style="color: #ff0000;">&quot;Error unpacking the profile tarball. You might want to use the backup tarball located in <span style="color: #007800;">${PFDIR}</span>.&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This tars up the profile</span>
packup<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">PACKLOCK</span>=<span style="color: #ff0000;">&quot;locked&quot;</span>  
  <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>&quot;</span>
  <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--exclude</span> <span style="color: #ff0000;">'.unpacked'</span> <span style="color: #660033;">-cpf</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>.packed.tmp.tar&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PROFILE}</span>&quot;</span>
  <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>.packed.tar&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>.packed.tar.old&quot;</span>
  <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>.packed.tmp.tar&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>.packed.tar&quot;</span>
  <span style="color: #007800;">PACKLOCK</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># No daemon, just packing</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(basename ${0})</span>&quot;</span> == <span style="color: #ff0000;">&quot;packfox&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> packup; <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># The daemon loop</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(basename ${0})</span>&quot;</span> == <span style="color: #ff0000;">&quot;packfox-daemon&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #c20cb9; font-weight: bold;">which</span> inotifywait <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> seppuku <span style="color: #ff0000;">&quot; You'll need the 'inotify-tools' package for this script. Get it at http://inotify-tools.sourceforge.net or from your distro's repos&quot;</span>.
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
    <span style="color: #000000; font-weight: bold;">do</span> inotifywait <span style="color: #660033;">-q</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-t</span> <span style="color: #800000;">${TMOUT}</span> <span style="color: #660033;">-e</span> modify <span style="color: #660033;">-e</span> move <span style="color: #660033;">-e</span> create <span style="color: #660033;">-e</span> delete <span style="color: #660033;">--exclude</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${IEXCL}</span>&quot;</span> \
    <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PFDIR}</span>/<span style="color: #007800;">${PROFILE}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
    <span style="color: #007800;">INOTYPID</span>=<span style="color: #800000;">${!}</span>
    <span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #800000;">${INOTYPID}</span>; <span style="color: #007800;">INOTIFYPID</span>=<span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
    packup
&nbsp;
    <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #800000;">${TMMIN}</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
    <span style="color: #007800;">SLEEPPID</span>=<span style="color: #800000;">${!}</span>
    <span style="color: #7a0874; font-weight: bold;">wait</span> <span style="color: #800000;">${SLEEPPID}</span>; <span style="color: #007800;">SLEEPPID</span>=<span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://smorgasbord.gavagai.nl/2009/05/how-i-fixed-my-firefox-hiccups/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

