Fight for the Internet 1!

Saturday, April 11, 2009

Speed up Firefox with TmpFS

This shows how to speed up Firefox by running it entirely from RAM to improve speed. Most of the credit for this article should go to here, from which I have taken most of this information, with the exception of improving his shell-script understandability.

Firefox uses SQLlite to store most of its information. As SQLite accesses are I/O bound, Firefox suffers when from disk drive bottleneck and competition for read/writes with other processes.

Create RAM partition

Add this entry in /etc/fstab:

firefox /home/xxxx/.mozilla/firefox/xxxxxxxx.default tmpfs size=128M,noauto,user,exec,uid=1000,gid=1000 0 0
Shell Script

WORKING_LOCATION="/home/jondoe/Sata/Linux/presets/home-configs" # Directory where RAM_DIR and LOCAL_DIR exist
jondoe/Sata/Linux/presets/home-configs/firefox3_ram" # Location mounted TmpFS
jondoe/Sata/Linux/presets/home-configs/firefox3_local" # Harddrive folder for out-of-RAM storage

#cd "$WORKING_LOCATION" # Switch to location of working location -- unnecessary if using absolute paths

if [ -z "$(mount | grep -F ${RAM_DIR} )" ]; then # Check if firefox TmpFS already mounted
# Not mounted
mount firefox # Mount it now

# The file '.unpacked_to_ram' is an indicator that we have synced into RAM
if [ ! -f "$RAM_DIR/.unpacked_to_ram" ]; then # Check if we have sync into RAM
echo "No file found indicating synced to RAM"
echo "Executing sync to RAM"
rsync -av --delete --exclude .unpacked_to_ram $LOCAL_DIR/* $RAM_DIR # Execute sync to RAM
echo "Creating note for synced to RAM"
touch "$RAM_DIR/.unpacked_to_ram" # Create note for synced into RAM
else # Already in RAM.
echo "Syncing Firefox3 TmpFS to local folder..."
rsync -av --delete $RAM_DIR/* $LOCAL_DIR # Sync back down to disk

*/5 * * * * jondoe bash /home/jondoe/ >> /home//cronlog.txt 2>&1

No comments:

Post a Comment