Author Topic: How to Stop Firefox from Devouring Your SSD (literal GB of daily writes to disk)  (Read 7586 times)

0 Members and 1 Guest are viewing this topic.

Offline RaymondMackTopic starter

  • Regular Contributor
  • *
  • Posts: 90
  • Country: us
So apparently excessive disk writes (on the order of multi-gigabytes per day) has been an issue with FF for a very long time.

I only became aware of this issue while optimizing my new Linux workstation where the Gnome System Monitor helpfully shows total disk writes per process. I was shocked at how much activity FF exhibited (>500 MiB disk writes) for only 15min of active use (loading a scant few web pages while configuring my setup).

Confused, but not necessarily alarmed, I attempted a search to see if I was just being paranoid (or whatever the computer equivalent of a hypochondriac is). Turns out that other people have noticed this behavior and have tried to curtail the write activity by editing setting in FF's about:config page:

https://www.servethehome.com/firefox-is-eating-your-ssd-here-is-how-to-fix-it/
https://www.reddit.com/r/firefox/comments/ufozuh/disable_browser_cache_in_firefox_so_you_dont/?rdt=62421

Code: [Select]
browser.sessionstore.interval - 1800000
browser.cache.disk.enable - false
browser.cache.disk_cache_ssl - false
and so on...

I had no luck with lessening FF's excessive write behavior using any of these options in about:config. On the other hand, these settings did help with Tor Browser, which is based on FF and has similar issues with massive disk writes for what amounts to ephemeral throw away browser sessions.

Que dramatic music: Arch Wiki and Profile-sync-daemon enter the chat.

https://wiki.archlinux.org/title/Firefox/Profile_on_RAM
https://wiki.archlinux.org/title/Profile-sync-daemon

Turns out the bulk of the disk activity is in the FF profile directory. This directory isn't very large, maybe 100 to 300 MiB, but the massive amount of activity it sees is surprising. Turns out moving this directory to a RAM disk solves the disk write issue and also speeds up FF. A real win-win. Do note that there is the possibility of losing session data (i.e. opened, unsynced tabs) in the event of a crash, power outage, or other disruption. So, like with all "fixes", there are caveats to consider.

So PSD neatly covers FF (and other browsers) for Linux. But what about Windows?

Well, I'm glad you asked, because I believe I have a pretty neat turn-key solution to this problem. And its very low effort too. But first, let's figure out how to profile this on Windows. Unfortunately, Windows Task Manager does not show total disk writes per process; however, Sysinternals Process Explorer does. Nice. That's step one. Next we need to see where writes are being made. Well, Windows Resource Monitor or Sysinternals Process Monitor can do this for us. I chose the later. Let Process Monitor run for a little bit then go to "Tools" -> "File Summary". This will show a list of all file activity since it has been running (so you may want to open and close Process Monitor periodically to speed things up). This lets us know what FF is doing and where its doing it. Finally we need CrystalDiskInfo. This utility lets us see the SSD's TBW metric in gigabytes, and is how we will prove that moving the profile directory into RAM actually does anything useful.

1862641-0

As shown above, I logged over 10 gigs of pointless writes to disk in less than 6 hours on my Win10 laptop! The laptop was docked and set to not go to sleep, since it was plugged into AC power. Firefox was ironically idle during much of this time. According to Windows Resource Monitor, some websites cause FF to exhibit persistent megabytes/second disk activity with zero user input. Wild.

1862647-1

This attachment shows FF profile activity on a RAM disk I made with drive label P. Clever, I know.

Okay, you've sold me! So how can I fix this on Windows? Well, it's pretty easy:

1) Download and install ImDisk Toolkit (https://sourceforge.net/projects/imdisk-toolkit/)

2) Close FF. Go to C:\Users\YOURUSERNAME\AppData\Roaming\Mozilla\Firefox and edit the two .ini files:

  installs.ini:
    add P:\ after Default=
    (so we should see "Default=P:\SOMEVALUE.default-SOMEVALUE")
  profiles.ini:
    set IsRelative=0
    add P:\ after Default= and Path= (like we did for installs.ini)

  Note: YOURUSERNAME is your account user name.

3) Setup a persistent 500MiB* RAM disk that copies your FF profile into memory and then saves it back to disk upon system shutdown or reboot. Yeah, this is the meat and potatoes bit. (*the disk takes up only as much space as need, so <500MiB in practice)

  Open Start, find the ImDisk subfolder and open RAM DiskConfiguration and input the settings in attachment 3.

1862653-2

  Note that the FF profile directory is located at:

    C:\Users\YOURUSERNAME\AppData\Roaming\Mozilla\Firefox\Profiles

  ImDisk will copy the contents of this directory to the new RAM drive P and sync files at boot/shutdown. Easy, peasy.

  Now open up FF. It will complain and ask you to setup your profile (since we edited the .ini files).
  Select Create Profile. Direct FF to the P drive and select your profile folder. FF should open up with all your saved tabs.
  If you made a mistake selecting the correct profile or directory: close FF, edit the .ini files again as per step 2) and reopen FF.

Note: To check that the profile on the P drive is being used, open up Process Monitor and look for FF activity on the P drive. (To simplify profiling, we can create a filter in Process Monitor to only show FF activity. Click Filter on the top bar then Filter on the drop down selection. Now change Architecture to Process Name and type firefox.exe in the blank box. The filter should show "[Process Name] [is] [firefox.exe] then [include]". Click OK to apply the filter.)

4) Set the new RAM drive to hidden. Go back to Start, ImDisk subfolder, open General Settings and check the box for P. Done.

1862659-3

So there you have it: PSD on Windows is basically ImDisk and a few file edits and redirecting FF to the new directory location. Neat.
« Last Edit: September 01, 2023, 10:24:08 pm by RaymondMack »
 
The following users thanked this post: bitwelder, coromonadalix, RoGeorge, D Straney, Yoppil

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 6590
  • Country: ca
in windows i use firemin who kills the excessive memory "leak"   i can use lots of opened windows ...

And yes FF or variants suffers the same ....  :--

AND  sadly i need some specific  added pluggins only available  in FF Waterfox  etc ...
« Last Edit: August 30, 2023, 11:03:43 am by coromonadalix »
 

Offline AntiProtonBoy

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: au
  • I think I passed the Voight-Kampff test.
This is not normal. Backup your profile folder and do a fresh install of Firefox and see what happens. I'd wager it's some kind of plugins issue.
 

Offline Infraviolet

  • Super Contributor
  • ***
  • Posts: 1152
  • Country: gb
This also shows the method for FF
https://easylinuxtipsproject.blogspot.com/p/ssd.html Section 9 and onwards
and shows the limited options available to approach doing the same for Chrome.

Note, it also makes sense to do the FF and Chrome changes on a HDD based computer, and it makes the browsers much faster to load when started.
 

Offline KaneTW

  • Frequent Contributor
  • **
  • Posts: 810
  • Country: de
Even the cheapest of consumer SSDs is rated for .3 DWPD, i.e. you can write 300GB on a 1TB client SSD every day and be fine for 5 years. Don't worry about it.
 
The following users thanked this post: Someone

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 6590
  • Country: ca
I keep cache size low ...

temp files are flushed on browser shutdown ...

And i do some memory management  ...

it will save some space and wear ...
 

Offline RaymondMackTopic starter

  • Regular Contributor
  • *
  • Posts: 90
  • Country: us
This is not normal. Backup your profile folder and do a fresh install of Firefox and see what happens. I'd wager it's some kind of plugins issue.

Both Linux and Win10 tests were fresh installs of FF 116.03 (for sanity checks on my end). The only add-ons installed were uBlock Origin (to get rid of adds) and h264iffy (for experimentation). FF by default has enormous amount of disk activity. If you don't believe me, simply profile your own system and be awed. Moving the FF profile directory to memory brings a whole host of benefits to system wide performance since we are minimizing the much slower disk to CPU pathway (even nvme disks are slower than RAM). The speed up should be most apparent on systems with SATA drives (SSD or HDD) and weak CPUs. Of course you will need about 200MiB or so of spare memory for this to work.
 

Offline RaymondMackTopic starter

  • Regular Contributor
  • *
  • Posts: 90
  • Country: us
Even the cheapest of consumer SSDs is rated for .3 DWPD, i.e. you can write 300GB on a 1TB client SSD every day and be fine for 5 years. Don't worry about it.

While I agree, I do care about improving performance when and where possible. Windows 10 has found new and innovative ways of reducing system performance/responsiveness with various "background tasks" that eat up disk active time, so relieving disk pressure speeds up the overall system responsiveness. Yeah, lets optimize .NET in the background, or run a performance assessment randomly while watching a video... I have seen some of the dumbest background tasks performed at the most inopportune times while actively using my Windows 10 system. This hit to performance is most apparent on weak HW like my Kabbylake era ultrabook.

Ironically, the oldest version of Windows 10 (LTSB 2015, Threshold 1) which has (seemingly) none of these new background "enhancements" is the most responsive version of Windows I have ever used (having minimal to no background CPU or disk activity not initiated by the user). Its better than even Windows 7. Unfortunately, getting drivers for LTSB 2015 is a bust for most HW.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15317
  • Country: fr
I guess it would depend on the usage obviously, but several GB of cache data per day if you're a heavy user, I'm not too surprised. I doubt that's very different with Chrome and others.

I've personally set up browser caches on a separate SSD, cheaper than the NVMe I use for the OS and my data. This separate SSD also hosts the swap partition.
This setup works pretty well.
This separate SSD is a SATA 512GB SSD (from a major vendor, not cheap crap) which is way fast enough for this and I got it for under $40. I don't care if it dies in 2 years, even though I doubt it will.

Doing that is rather straightforward: https://support.mozilla.org/en-US/questions/1317032

 

Offline alligatorblues

  • Regular Contributor
  • *
  • Posts: 155
  • Country: us
I switched to brave browser.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15317
  • Country: fr
I switched to brave browser.

And does it cache less stuff?
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3540
  • Country: es
I switched to brave browser.
The main reason I use Brave is because I can see Youtube videos without the constant interruption for ads.
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15317
  • Country: fr
I switched to brave browser.
The main reason I use Brave is because I can see Youtube videos without the constant interruption for ads.

I get the same (at least for now) with Firefox and the right extensions.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15317
  • Country: fr
Speaking of Firefox, I updated to the latest 118.0.
They have introduced embedded website translation, which by default automatically pops up (which is pretty annoying), but you can disable these pop-ups in the pop-up itself.

Other than this, I have noticed a more general, new behavior: it seems to take more CPU time overall when idle - Firefox in the background with many tabs open - than it used to. To figure it out, I looked at about:processes. It appears that the incremental garbage collector kicks in way more often than in previous versions. The effect of this seems to be a lower RAM usage - at least that how it looks so far for about the same tabs open and same conditions. I'll see after it has run for a longer time.

Oddly, I haven't seen anything about this mentioned in the change log. At least the summary - I haven't looked at the detailed change log. But if they have changed anything like this, I think it would have been worth mentioning.
Curious to see if others notice the same thing.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf