Mount firefox cache folder in tmpfs by default.

Write suggestions and new ideas in here
More ideas here http://community.linuxmint.com/idea/welcome
Forum rules
  • Only post ideas here that are specifically about the Linux Mint distribution or its websites.
  • So that developers and users from any distribution can discuss ideas in one place, post ideas about improving software to the collaboration website for that software instead.
Post Reply
szamot83
Level 2
Level 2
Posts: 66
Joined: Wed Jul 23, 2008 9:33 am

Mount firefox cache folder in tmpfs by default.

Post by szamot83 »

Today I have mounted Firefox cache folder in tmpfs. I see that this speed up this app.
I have made this in that way:
1 terminal:

Code: Select all

sudo mkdir /mnt/ffcache
2 terminal:

Code: Select all

sudo mousepad /etc/fstab
and add this line:

Code: Select all

tmpfs /mnt/ffcache tmpfs size=100M,mode=1777 0 0 
of course 100mb is too high, but this is only for test.
3 Firefox - go to

Code: Select all

about:config
3a for firefox 3.1 - find

Code: Select all

browser.cache.disk.parent_directory
double click and change value to:

Code: Select all

/mnt/ffcache
3b for firefox 3.5 - click right mouse button, choose add string

Code: Select all

browser.cache.disk.parent_directory
than double click on it, and paste there:

Code: Select all

/mnt/ffcache
Reboot your system, and check it.

This is only proposition, what do you say about it?

emorrp1
Level 8
Level 8
Posts: 2158
Joined: Thu Feb 26, 2009 8:58 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by emorrp1 »

I doubt it'll happen by default, as it bumps the minimum RAM requirements up by another 100MB, but following your hint, I'm now running my entire firefox (3.5) profile in ram by following this guide: http://www.verot.net/firefox_tmpfs.htm and it's now blazing fast!
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com

User avatar
optimize me
Level 5
Level 5
Posts: 625
Joined: Wed Jun 03, 2009 5:25 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by optimize me »

Off topic, maybe deserving of a new thread:
emorrp1 wrote:I doubt it'll happen by default, as it bumps the minimum RAM requirements up by another 100MB, but following your hint, I'm now running my entire firefox (3.5) profile in ram by following this guide: http://www.verot.net/firefox_tmpfs.htm and it's now blazing fast!
Did you have to modify the tmpfs_firefox.sh script to make that how-to work? I tried following that version, and the original at Gentoo Forums, and all I ever get when I try to open FF for the first time after running the script is a blank profile, as if I had just finished installing Mint and ran FF for the first time.

It seems to me that he tells you to copy your profile into a newly created folder ~/.mozilla/firefox/profile, then to empty your original ********.default profile folder, but then the script calls on your original ********.default profile folder to mount as the tmpfs profile in RAM.

Did I miss a step? Am I blind?
AMD Phenom II X6 1045T 2.8GHz 8GB DDR3 RAM ATI Radeon HD6970

emorrp1
Level 8
Level 8
Posts: 2158
Joined: Thu Feb 26, 2009 8:58 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by emorrp1 »

The only bit I had to modify was the firefox directory it was using in order to work with ff 3.5 (apparently it uses a separate directory). After that, it had my history and everything, but for some reason it ignored my extensions, as I don't think I copied them over to the profile folder correctly, but I had a backup (always useful when a rm -Rf instruction is given), so a quick copy across of the extensions folder solved that. Oh, and I had to increase the tmpfs size, as my profile is larger than 100M, since I didn't reduce the cache size. Then a simple crontab -e allowed me to add the backup, but I only set it to every half an hour. I then modified the global firefox link (/usr/bin/firefox) to point to my start_firefox script (to save me customising all the launchers) I've commented my adjusted tmpfs_firefox script for you:

Code: Select all

#!/bin/sh
# http://www.verot.net/firefox_tmpfs.htm

# adjust these settings to your setup
PROFILE='hm3xec2j.default'
FFDIR="${HOME}/.mozilla/firefox-3.5/"
cd "${FFDIR}"

# check if we're working in tmpfs
if test -z "$(mount | grep -F "${FFDIR}${PROFILE}" )"
then
    # if not, make it work in tmpfs
    mount "${FFDIR}${PROFILE}"
fi

# check if the profile has been copied to tmpfs
if test -f "${PROFILE}/.unpacked"
then
    # if so, sync the old profile from the tmpfs one
    rsync -av --delete --exclude .unpacked ./"$PROFILE"/ ./profile/
else
    # if not, copy it over
    rsync -av ./profile/ ./"$PROFILE"/
    touch "${PROFILE}/.unpacked"
fi

exit
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com

User avatar
optimize me
Level 5
Level 5
Posts: 625
Joined: Wed Jun 03, 2009 5:25 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by optimize me »

emorrp1 wrote:The only bit I had to modify was the firefox directory it was using in order to work with ff 3.5 (apparently it uses a separate directory). After that, it had my history and everything, but for some reason it ignored my extensions, as I don't think I copied them over to the profile folder correctly, but I had a backup (always useful when a rm -Rf instruction is given), so a quick copy across of the extensions folder solved that. Oh, and I had to increase the tmpfs size, as my profile is larger than 100M, since I didn't reduce the cache size. Then a simple crontab -e allowed me to add the backup, but I only set it to every half an hour. I then modified the global firefox link (/usr/bin/firefox) to point to my start_firefox script (to save me customising all the launchers) I've commented my adjusted tmpfs_firefox script for you:

Code: Select all

#!/bin/sh
# http://www.verot.net/firefox_tmpfs.htm

# adjust these settings to your setup
PROFILE='hm3xec2j.default'
FFDIR="${HOME}/.mozilla/firefox-3.5/"
cd "${FFDIR}"

# check if we're working in tmpfs
if test -z "$(mount | grep -F "${FFDIR}${PROFILE}" )"
then
    # if not, make it work in tmpfs
    mount "${FFDIR}${PROFILE}"
fi

# check if the profile has been copied to tmpfs
if test -f "${PROFILE}/.unpacked"
then
    # if so, sync the old profile from the tmpfs one
    rsync -av --delete --exclude .unpacked ./"$PROFILE"/ ./profile/
else
    # if not, copy it over
    rsync -av ./profile/ ./"$PROFILE"/
    touch "${PROFILE}/.unpacked"
fi

exit
So, OK - what about the entry added to fstab? I notice it points to the original ********.default profile directory, but the all the profile information has been copied to the newly created profile directory, and then erased from the original location.

Should the fstab entry point to the new location?

I'm doing something wrong because even with your script (changed to contain my file locations), I'm still getting a blank, default, "new" firefox. It does run faster, I'll give it that.. but then again, without my 24 extensions and close to 2000 bookmarks, how could it run slow?
AMD Phenom II X6 1045T 2.8GHz 8GB DDR3 RAM ATI Radeon HD6970

User avatar
optimize me
Level 5
Level 5
Posts: 625
Joined: Wed Jun 03, 2009 5:25 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by optimize me »

optimize me wrote:
emorrp1 wrote:The only bit I had to modify was the firefox directory it was using in order to work with ff 3.5 (apparently it uses a separate directory). After that, it had my history and everything, but for some reason it ignored my extensions, as I don't think I copied them over to the profile folder correctly, but I had a backup (always useful when a rm -Rf instruction is given), so a quick copy across of the extensions folder solved that. Oh, and I had to increase the tmpfs size, as my profile is larger than 100M, since I didn't reduce the cache size. Then a simple crontab -e allowed me to add the backup, but I only set it to every half an hour. I then modified the global firefox link (/usr/bin/firefox) to point to my start_firefox script (to save me customising all the launchers) I've commented my adjusted tmpfs_firefox script for you:

Code: Select all

#!/bin/sh
# http://www.verot.net/firefox_tmpfs.htm

# adjust these settings to your setup
PROFILE='hm3xec2j.default'
FFDIR="${HOME}/.mozilla/firefox-3.5/"
cd "${FFDIR}"

# check if we're working in tmpfs
if test -z "$(mount | grep -F "${FFDIR}${PROFILE}" )"
then
    # if not, make it work in tmpfs
    mount "${FFDIR}${PROFILE}"
fi

# check if the profile has been copied to tmpfs
if test -f "${PROFILE}/.unpacked"
then
    # if so, sync the old profile from the tmpfs one
    rsync -av --delete --exclude .unpacked ./"$PROFILE"/ ./profile/
else
    # if not, copy it over
    rsync -av ./profile/ ./"$PROFILE"/
    touch "${PROFILE}/.unpacked"
fi

exit
So, OK - what about the entry added to fstab? I notice it points to the original ********.default profile directory, but the all the profile information has been copied to the newly created profile directory, and then erased from the original location.

Should the fstab entry point to the new location?

I'm doing something wrong because even with your script (changed to contain my file locations), I'm still getting a blank, default, "new" firefox. It does run faster, I'll give it that.. but then again, without my 24 extensions and close to 2000 bookmarks, how could it run slow?
EDIT: OK, scratch that - I got it to work. There were still wrong paths set in the start-firefox script. Not sure how I missed that... A number of things didn't transfer over (like saved passwords and extensions) but I'm sure I can take it from here. Thanks for the assist!
AMD Phenom II X6 1045T 2.8GHz 8GB DDR3 RAM ATI Radeon HD6970

szamot83
Level 2
Level 2
Posts: 66
Joined: Wed Jul 23, 2008 9:33 am

Re: Mount firefox cache folder in tmpfs by default.

Post by szamot83 »

I think that "dnotify" could be usefull in this case.

I can't write scripts, but I'll try to add this into code above.


Sorry for my English

emorrp1
Level 8
Level 8
Posts: 2158
Joined: Thu Feb 26, 2009 8:58 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by emorrp1 »

szamot83: dnotify is depreciated in favour of inotify. However, copying every single change back to disk is completely unnecessary in my opinion (I only set mine to sync every half an hour, rather than 5 mins), as it's only if you're computer looses power in between syncs that you'll loose any data. If you close firefox, the tmpfs is still there (which is a good thing, as it speeds up firefox starting time too) However, it's a free world, so go ahead.
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com

szamot83
Level 2
Level 2
Posts: 66
Joined: Wed Jul 23, 2008 9:33 am

Re: Mount firefox cache folder in tmpfs by default.

Post by szamot83 »

I can't get this to work.
I'll try again.

http://www.verot.net/firefox_tmpfs.htm
On this site author write that I should add following line to fstab:

Code: Select all

firefox /home/xxxx/.mozilla/firefox/xxxxxxxx.default tmpfs size=128M,noauto,user,exec,uid=1000,gid=1000 0 0
What means firefox in the beginning? Maybe this should be tmpfs?


If you could tell me - how you set synchronizing at every 30 min?

Again sorry for my English. I hope that you understand me.
Regards

emorrp1
Level 8
Level 8
Posts: 2158
Joined: Thu Feb 26, 2009 8:58 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by emorrp1 »

Your english is fine. The firefox in the fstab is just a label for tmpfs (which is specified as the filesystem in the third column) I suppose you could change it to whatever you want, including "tmpfs" but there wouldn't be much point (the label is used to identify the "device" in system monitor) To add the script to run every 30 mins, run the "crontab -e" command, adding the line "*/30 * * * * /path/to/tmpfs_firefox" and saving it. I'll probably turn this into a full how-to at some point.
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com

szamot83
Level 2
Level 2
Posts: 66
Joined: Wed Jul 23, 2008 9:33 am

Re: Mount firefox cache folder in tmpfs by default.

Post by szamot83 »

Full howto - this would be great.

Thanks for reply. I'll try this.

User avatar
Fred
Level 10
Level 10
Posts: 3337
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Mount firefox cache folder in tmpfs by default.

Post by Fred »

Something to keep in mind when using tmpfs. Give some thought to how large your tmpfs file system should be for the task at hand. Tmpfs doesn't preallocate the space you select. The file memory setting is the maximum the file system can grow to before going into swap. When the memory limits set in your fstab are exceeded it goes directly into swap instead of freezing or consuming more RAM.

This has advantages as well as disadvantages. The big disadvantage here is if you undersize tmpfs it will start using swap and you will loose any speed gains. If it is a notebook not only will you start getting a lot of disk accesses, which is hard on the drive, but your power consumption will climb.

You might also consider using tmpfs on /tmp. On a stable system there is usually nothing there that is needed from one boot to another, so no file copying is necessary.

Just a couple of considerations. :-)

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.

emorrp1
Level 8
Level 8
Posts: 2158
Joined: Thu Feb 26, 2009 8:58 pm

Re: Mount firefox cache folder in tmpfs by default.

Post by emorrp1 »

Thanks Fred, I had noticed that, so I bumped it up to 200M just for kicks. I was wondering what other places it would be useful, as I don't use most of my RAM except when using VMs (which do pre-allocate)
If you have a question that has been answered and solved, then please edit your original post and put a [SOLVED] at the end of your subject header
Hint - use a google search including the search term site:forums.linuxmint.com

szamot83
Level 2
Level 2
Posts: 66
Joined: Wed Jul 23, 2008 9:33 am

Re: Mount firefox cache folder in tmpfs by default.

Post by szamot83 »

I have mounted ~/.thumbnails folder in that way. It has better performance now - I mean thumbnails appearing faster than earlier.

It's a pity that thumbnails folder could not be changed - If I could do this, than I could mount this globally (for all users).

Post Reply

Return to “Suggestions & New Ideas”