Skip to content

让你的firefox飞起来

2011 五月 28
by 荒野无灯

此方法主要是针对由于磁盘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 脚本的前面四行:

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进程,它还能正确同步信息么?

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:,欢迎点击这里捐赠以支持荒野无灯转播到腾讯微博 转播到腾讯微博

作者:荒野无灯
出处:Hacklog【Hacklog】

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】

本文链接: http://ihacklog.com/?p=4510

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <q cite=""> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS