让你的firefox飞起来
此方法主要是针对由于磁盘IO瓶颈而使Firefox 浏览速度变慢这一问题。
Speed up Firefox with tmpfs一文中说道:
Firefox uses SQLlite to store most of its information, which makes it quite slow. As SQLite accesses are IO-bound, Firefox suffers when the disk is heavily used by other processes. Here is a solution to move the profile is a RAM partition, using tmpfs. Note that this solution has been exposed here. I am just presenting a modified solution, which uses rsync to sync the profile on RAM and on disk.
这里主要用到speedfox这个脚本,来自于:speeding up firefox with tmpfs and automatic rsync
这是2009年的文章了,可惜我现在才看到。。。
但是这个方案的不足之处是 需要额外修改/etc/fstab,操作比较麻烦。
其实LINUX下一般都已经自动有了一个映射内存的设备: /dev/shm
不信?查看下你的fstab ,里面是不是有这么一行:
1 | shm /dev/shm tmpfs nodev,nosuid 0 0 |
speedfox 下载 (2.1 KB, 2 次)
然后修改speedfox 脚本的前面四行:
1 2 3 4 5 6 7 8 9 10 11 12 | # your ram mozilla folder MOZTMPFS=/dev/shm/`whoami`_mozilla # your original mozilla folder - i recommend: mv ~/.mozilla ~/.mozilla-hdd #这个是重合名以后的配置文件目录名 MOZHDD="${HOME}/.mozilla/firefox/trz5g6kg.default-hdd" # your ~/.mozilla #如果你的firefox只有一个profile, # 那么一般是结尾为default的那个目录。这个变量主要用于生成软链,因为ff启动时会读取此配置文件 MOZHOME="${HOME}/.mozilla/firefox/trz5g6kg.default" # seconds interval for rsync #同步的时间间隔,单位秒 INTERVAL=600 |
这里我还修改了一处(加了个参数):
1 | firefox $1 |
然后 firefox.desktop 里面就可以用这个了:
1 | Exec=/home/admin/scripts/speedfox %u |
这个脚本的原理就是在ff启动时将MOZHDD 文件的内容映射到tmpfs ,然后 MOZHOME 作为软链指向 tmpfs ,这样FF就从内存中读取配置信息等东东了,速度能不快么?然后,这个脚本同时还隔 INTERVAL 秒的时间把tmpfs 里面的配置同步到 硬盘(MOZHDD 文件)。这样下次启动时信息就不会丢失。当ff退出时,自动清除建立的软链,并同步tmpfs中的内容到硬盘。
我想到一个问题就是,假如打开了多个ff进程,它还能正确同步信息么?





