SSD性能优化

SSD固态硬盘的使用寿命其实挺高的,高到电脑坏了硬盘还是好的。可是,这毕竟是理论上的,我还是想更加优化它的性能,而且还能提升应用响应时间。

修改ext4系统文件信息的统计

The ext4 file system records information about when a file was last accessed and there is a cost associated with recording it. With the noatime option, the access timestamps on the filesystem are not updated.

修改relatimenoatime

1
2
3
4
5
vim /etc/fstab
# /dev/nvme0n1p5
UUID=ef088753-8f19-40a7-bcbf-a6849aa8d7ff / ext4 rw,noatime 0 1
# /dev/nvme0n1p6
UUID=650ad4a2-cbea-4bc2-af3a-01fdfa7b02f5 /home ext4 rw,noatime 0 2

增加commit时间

The default 5 sec means that if the power is lost, one will lose as much as the latest 5 seconds of work.
It forces a full sync of all data/journal to physical media every 5 seconds.

将默认的5s改为60s

1
2
3
4
# /dev/nvme0n1p5
UUID=ef088753-8f19-40a7-bcbf-a6849aa8d7ff / ext4 rw,noatime,commit=60 0 1
# /dev/nvme0n1p6
UUID=650ad4a2-cbea-4bc2-af3a-01fdfa7b02f5 /home ext4 rw,noatime,commit=60 0 2

将临时文件载入内存中

tmpfs is a temporary filesystem that resides in memory and/or swap partition(s). Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

1
2
3
4
5
6
7
8
9
10
11
12
#由于使用了systemd,它已经将tmpfs自动挂载到了/tmp下
Filesystem Size Used Avail Use% Mounted on
dev 3.8G 0 3.8G 0% /dev
run 3.9G 1.2M 3.9G 1% /run
/dev/nvme0n1p5 30G 12G 17G 43% /
tmpfs 3.9G 91M 3.8G 3% /dev/shm
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 3.9G 12K 3.9G 1% /tmp
/dev/nvme0n1p6 203G 22G 172G 12% /home
tmpfs 779M 20K 779M 1% /run/user/1000

# systemctl status tmp.mount

如果没有则手动添加

1
tmpfs   /tmp         tmpfs   rw,nodev,nosuid,size=2G          0  0

浏览器firefox优化

关闭磁盘缓存
1
2
3
4
5
An alternative approach is to use about:config settings:

Set browser.cache.disk.enable to false
Verify that browser.cache.memory.enable is set to true
Add the entry (right click > new > integer) browser.cache.memory.capacity and set it to the amount of KB you want to spare, or to -1 for automatic cache size selection (skipping this step has the same effect as setting the value to -1)
增加会话保存时间间隔(或者关闭)

Firefox stores the current session status (opened urls, cookies, historyand form data) to the disk on a regular basis. It is used to recover a previous session in case of crash.The default setting is to save the session every 15 seconds, resulting
in frequent disk access.

1
2
3
To increase the save interval to 10 minutes (600000 milliseconds) for example, change in about:config the setting of browser.sessionstore.interval to 600000

To disable completely this feature, change browser.sessionstore.resume_from_crash to false
Disable Pocket

If you do not use the Pocket-service, you may want to disable it by setting extensions.pocket.enabled to false in about:config.


Profile-sync-daemon(psd):通过tmpfs将所有文件放入内存,Cache the entire profile into RAM via tmpfs
安装:
1
sudo pacman -S profile-sync-daemon
首次运行:
1
2
psd
First time running psd so please edit /home/jc/.config/psd/psd.conf to your liking and run again.
1
2
3
#添加firefox
vim .config/psd/psd.conf
BROWSERS="firefox"
启动
1
2
3
systemctl --user start psd.service
systemctl --user enable psd.service
Created symlink /home/jc/.config/systemd/user/default.target.wants/psd.service → /usr/lib/systemd/user/psd.service.
查看
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
psd p

Profile-sync-daemon v6.34 on Arch Linux

Systemd service is currently active.
Systemd resync-timer is currently active.
Overlayfs technology is currently inactive.

Psd will manage the following per /home/jc/.config/psd/psd.conf:

browser/psname: firefox/firefox
owner/group id: jc/1001
sync target: /home/jc/.mozilla/firefox/1auapu8j.default
tmpfs dir: /run/user/1000/jc-firefox-1auapu8j.default
profile size: 8.0K
recovery dirs: none

browser/psname: firefox/firefox
owner/group id: jc/1001
sync target: /home/jc/.mozilla/firefox/iv3atepa.default-release
tmpfs dir: /run/user/1000/jc-firefox-iv3atepa.default-release
profile size: 31M
recovery dirs: none

anything-sync-daemon同步任意文件到内存中

安装:
1
sudo pacman -S anything-sync-daemon
编辑:
1
2
3
vim /etc/asd.conf

WHATTOSYNC=('/srv/http')
启动:
1
2
3
4
sudo systemctl start asd.service
sudo systemctl enable asd.service

Created symlink /etc/systemd/system/multi-user.target.wants/asd.service → /usr/lib/systemd/system/asd.service.
查看:
1
asd p