Après avoir lu un article sur Spotify qui écrit comme un fou sur le SSD, et m'être souvenu d'un autre article pointant le même problème à propos de Firefox, j'ai regardé rapidement : 300ko/s en continu par Firefox ! Pas étonnant que j'écrive 2.5Go/h en moyenne...
Du coup je teste le profil en RAM, merci le wiki ArchLinux <3
(Copie pour la postérité)
Place profile in RAM manually
Before you start
Before potentially compromising Firefox's profile, be sure to make a backup for quick restoration. Replace xyz.default
as appropriate and use tar
to make a backup:
$ tar zcvfp ~/firefox_profile_backup.tar.gz ~/.mozilla/firefox/xyz.default
The script
Adapted from verot.net's Speed up Firefox with tmpfs
The script will first move Firefox's profile to a new static location, make a sub-directory in /dev/shm, softlink to it and later populate it with the contents of the profile. As before, replace the bold sections to suit. The only value that absolutely needs to be altered is, again, xyz.default
.
Be sure that rsync
is installed and save the script to ~/bin/firefox-sync
, for example:
#!/bin/sh
static=main
link=xyz.default
volatile=/dev/shm/firefox-$USER
IFS=
set -efu
cd ~/.mozilla/firefox
if [ ! -r $volatile ]; then
mkdir -m0700 $volatile
fi
if [ "$(readlink $link)" != "$volatile" ]; then
mv $link $static
ln -s $volatile $link
fi
if [ -e $link/.unpacked ]; then
rsync -av --delete --exclude .unpacked ./$link/ ./$static/
else
rsync -av ./$static/ ./$link/
touch $link/.unpacked
fi
Close Firefox, make the script executable and test it:
$ killall firefox firefox-bin
$ chmod +x ~/bin/firefox-sync
$ ~/bin/firefox-sync
Run Firefox again to gauge the results. The second time the script runs, it will then preserve the RAM profile by copying it back to disk.
Automation
Seeing that forgetting to sync the profile can lead to disastrous results, automating the process seems like a logical course of action.
cron job
Manipulate the user's cron table using crontab
:
$ crontab -e
Add a line to start the script every 30 minutes,
*/30 * * * * ~/bin/firefox-sync
or add the following to do so every 2 hours:
0 */2 * * * ~/bin/firefox-sync
Sync at login/logout
Assuming bash is being used, add the script to the login/logout files:
$ echo '~/bin/firefox-sync' | tee -a ~/.bash_logout ~/.bash_login >/dev/null
Note: You may wish to use ~/.bash_profile
instead of ~/.bash_login
as bash will only read the first of these if both exist and are readable.
Note de moi-même : avec zsh
, ce sont les fichiers .zlogin
et .zlogout
.
— Permalink