How to Stop Firefox from Devouring Your SSD (literal GB of daily writes to disk) - Page 1
Forum section: electronics / general

author: RaymondMack
author_rank: Regular Contributor
timestamp: August 30, 2023, 10:56:15 am
content: 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=62421Code:browser.sessionstore.interval - 1800000browser.cache.disk.enable - falsebrowser.cache.disk_cache_ssl - falseand 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 settingsdidhelp 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_RAMhttps://wiki.archlinux.org/title/Profile-sync-daemonTurns 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.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.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=0add 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.Note that the FF profile directory is located at:C:\Users\YOURUSERNAME\AppData\Roaming\Mozilla\Firefox\ProfilesImDisk 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]  [firefox.exe] then ". 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.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.

author: coromonadalix
author_rank: Super Contributor
timestamp: August 30, 2023, 11:02:03 am
content: 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 ...

author: AntiProtonBoy
author_rank: Frequent Contributor
timestamp: August 30, 2023, 11:54:40 am
content: 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.

author: Infraviolet
author_rank: Super Contributor
timestamp: August 30, 2023, 02:52:42 pm
content: This also shows the method for FFhttps://easylinuxtipsproject.blogspot.com/p/ssd.htmlSection 9 and onwardsand 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.

author: KaneTW
author_rank: Frequent Contributor
timestamp: August 30, 2023, 03:04:29 pm
content: 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.

author: coromonadalix
author_rank: Super Contributor
timestamp: August 30, 2023, 03:10:04 pm
content: 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 ...

author: RaymondMack
author_rank: Regular Contributor
timestamp: August 30, 2023, 06:56:58 pm
content: Quote from: AntiProtonBoy on August 30, 2023, 11:54:40 amBoth 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.

author: RaymondMack
author_rank: Regular Contributor
timestamp: August 30, 2023, 07:18:53 pm
content: Quote from: KaneTW on August 30, 2023, 03:04:29 pmWhile 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.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 30, 2023, 08:39:54 pm
content: 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

author: alligatorblues
author_rank: Regular Contributor
timestamp: September 17, 2023, 04:25:12 pm
content: I switched to brave browser.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 17, 2023, 08:32:33 pm
content: Quote from: alligatorblues on September 17, 2023, 04:25:12 pmAnd does it cache less stuff?

author: soldar
author_rank: Super Contributor
timestamp: September 26, 2023, 12:08:03 pm
content: Quote from: alligatorblues on September 17, 2023, 04:25:12 pmThe main reason I use Brave is because I can see Youtube videos without the constant interruption for ads.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 26, 2023, 08:56:55 pm
content: Quote from: soldar on September 26, 2023, 12:08:03 pmI get the same (at least for now) with Firefox and the right extensions.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 26, 2023, 10:17:56 pm
content: 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.