If you are a user of Firefox we have a must-change setting. Today’s modern multi-core processor systems and higher quantities of RAM allow users to open multiple Firefox tabs and windows simultaneously. This can have an unintended effect for those SSDs as session store data can write data constantly to NAND. This issue is being discussed in a STH forum thread where you can follow the discussion.
Observing the Issue: Heavy SSD Writes from Firefox
Purely by chance, I fired up a free copy of SSDLife on two consecutive days where I haven’t really used my workstation for anything other than email and browsing. For those of you unfamiliar with this tool, it simply reports estimated lifetime for the attached SSD and it also shows the amount of data read and written.
In my case, SSDLife notified me that 12GB was written to the SSD in one day. Since I didn’t recall downloading any huge files over the previous day or visiting any new sites that could’ve resulted in bringing down a lot of new content to the cache, this puzzled me. I monitored these stats over the next couple of weeks and this behavior stayed consistent. Even if the workstation was left idle with nothing running on it but a few browser windows, it would invariably write at least 10GB per day to the SSD.
To find out what’s going on, I fired up Resource Monitor and looked at disk utilization.
At the very top of the list was Firefox, writing tirelessly at anywhere between 300K and 2MB per second to a file called “recovery.js”. Researching revealed that this is Firefox’s session backup file that is used to restore your browser sessions in case of a browser or an OS crash. That is extremely useful functionality. I was aware of the fact that Firefox had this feature, but I had no idea that session information was so heavy!
Researching the issue a bit more over the next day, I discovered that things are worse than I originally thought and “recovery.js” isn’t the only file involved. In case someone wants to replicate, here’s what I did this morning:
- I reset browser.sessionstore.interval to 15000 and then got rid of all my currently open FF windows.
- I opened a single window with just Google running in it, left it sitting for a couple of minutes, and then closed it.
- I started the browser again and on this final restart the recovery.js file was only 5KB in size, down from around 900KB before.
- Next, I opened a bunch of random reviews for Samsung 850 pro and Samsung Galaxy S7 in two separate windows. Simply searched for “samsung 850 pro review” and “samsung galaxy s7 review” and then went down the list of results opening them in new tabs.
- I opened a 3rd window and created a bunch of tabs showing front pages for various news sites.
- I launched Process Monitor and configured it to track recovery.js and cookie* files:
- I went to File->Capture Events and disabled it. Cleared all events that were currently showing up.
- I went back to File->Capture Events and re-enabled it. Left the three FireFox windows sitting idle for 45 minutes while I was using Chrome instead.
- Then I went to Tools->File Summary to get overall stats.
- Firefox managed to write 1.1GB to disk with the vast majority of data going into cookie* files.
Note that recovery.js managed to accumulate only about 1.3MB of writes.
I went back to one of the Firefox windows and opened my outlook.com mailbox. Cleared all events in Process Monitor and re-started the capture. Again, I left all Firefox windows sitting idle, but only for ~10 minutes. This time recovery.js was at ~1.5MB and it took only about 1/4-th of the time to get there. Cookie* files had a ton of data written to them, as before.
Depending on what you’ve got open in your tabs, Firefox could be dumping tons of data into recovery.js, cookie* files, or both. Running at 1.1GB for every 45 minutes, you’re looking at ~35GB/day written to your SSD if you leave your machine running. And at least in my case this wasn’t even the worst example of how much data could be going into recovery.js. In my original tests I clocked Firefox at 2MB/s writing to this file and the writing thread never went dead always showing up on the top of the list in Resource Monitor.
The Easy Fix
After some digging, I found out that this behavior is controlled by a parameter that you can access through typing “about:config” in the address bar. This parameter is called: —browser.sessionstore.interval
It is set to 15 seconds by default. In my case, I reset it to a more sane (at least for me) 30 minutes. Since then, I’m only seeing about 2GB written to disk when my workstation is left idle, which still feels like a lot but is 5 times less than before.
Bottom line is that if you have a lower capacity consumer level SSDs in some of your machines, you may want to check and tweak your Firefox config. Those drives can be rated for about 20GB of writes per day and Firefox alone might be using more than half of that. This is especially true if you’re like me and have a several browser windows open at all times each with numerous tabs. Changing this parameter may even help with normal HDDs. Your machine will feel faster if it doesn’t have to constantly write this session info. We have seen in the STH forum thread that content open in browser does have a major impact on writes as does the number of open windows and tabs. If you are using Firefox and a lower write endurance SSD you should check this immediately.
If you are wondering how this compares to real-world enterprise SSD usage, STH did a study buying hundreds of used enterprise/ datacenter SSDs off of ebay and checking SMART data for actual DWPD usage. See: Used enterprise SSDs: Dissecting our production SSD population
Update 1: We are testing other browsers. Currently in the middle of a Chrome Version 52.0.2743.116 m test. We have been able to see a pace of over 24GB/ day of writes on this machine (see here.)
Is there any indication that Thunderbird is doing this as well?
Thanks, Sergei. Observing similar behavior with:
Vivaldi 1.5.609.8 (Developer Build) (32-bit). just looking at the I/O Write Bytes column in Process Explorer. Launched this Vivaldi session ~40 ago, some of the child processes (Twitter tabs?) have written as much as 1.4 GB to date.
I cannot reproduce this while Firefox is idle. It seems that data is only written, when i change something in Firefox, e.g. if I scroll down a page i see a write a few seconds later. This makes total sense to me, as the session has changed.
-> May it be, that some websites or plugins or you ff constantly change the session data? can you reproduce this problem without any plugins on simple html sites? I am also using u Block, maybe some updated banners or something like that cause a change?
(I am using the Linux Version 45.4.0 (64 bit) o FF on Gentoo)
In looking at the parameters, it shows 15000 for the value, I’m guessing to multiply that by 4 to get the minute and then by 30 to get to 30 minutes for the refresh?
That value is stored in milliseconds (1 second = 1000 ms). So, in order to change it to 30 minutes, you would do the following:
(1000 * 60 * 60) * 30 = 108000000
(1m) (f) (ms)
Here’s the definition of those labels:
ms = millisecond
s = second
m = minute
h = hour
d = day
w = week
And some constant values to help you along:
1s = 1000 (base)
1m = 1000 * 60 = 60000
1h = 1000 * 60 * 60 = 3600000
1d = 1000 * 60 * 60 * 24 = 86400000
1w = 1000 * 60 * 60 * 24 * 7 = 604800000
Hi, I’m one of the Firefox developers who was in charge of Session Restore, so I’m one of the culprits of this heavy SSD I/O. To make a long story short: we are aware of the problem, but fixing it for real requires completely re-architecturing Session Restore. That’s something we haven’t done yet, as Session Restore is rather safety-critical for many users, so this would need to be done very carefully, and with plenty of manpower.
Is there a setting to shut off this feature manually?
Or do we need to increase the interval to ridiculous high values?
Does Firefox also do this when you close it? Can I set it to a high interval and still be sure to get my session, assuming that Firefox has been closed properly the last time?
Of course, as usual in an open-source project, contributors would be appreciated 🙂
It would be great if you’d remind people that the unit of “browser.sessionstore.interval” is MICROSECONDS,
If people set it to a value like “15” and not “15000” for a 15 second interval (default in FF), they might have a write every 15/1000 of a second, with far more devastating results!
Hint: to set it to half an hour the correct value would be 1800000 = 1.800.000 (1.8 Million)
That’s milliseconds. If it were microseconds, 1.8 million would be just shy of 2 seconds.
Sorry, mixed up prefix name.
I’m running Firefox 49 on Xubuntu 14.04 LTS and browser.sessionstore.interval is set to 15,000
Bug report for follow-up: https://bugzilla.mozilla.org/show_bug.cgi?id=1304389
“Cookie* files had a ton of data written to them, as before.”
Should be good to see other browsers behavior and see it they do the same, I wouldn’t be surprised if all others do this, because it seems to be bound to sites abusing of javascript (intersitials, tracking) and therefore creating cookies.
Tried an 80 tab Chrome run for an hour, ~1GB/ hour written and cookies were about 15-20% of that.
That’s still 24GB/DAY, still too much. Also Chrome manages things differently, which files got the most I/O in your case?
You can see a sample here: https://forums.servethehome.com/index.php?threads/firefox-is-chewing-through-your-nand.11346/page-2#post-108407
Another fix is to stop using Firefox.
Chrome is less offending with this issue (12GB/Day less than FF), but in the other hand it eats a lot of RAM making things slower, it’s time for all browser developers to revamp their creations and also this is a signal to websites to stop overusing scripts, they run several times per second so the “site” changes very often and new status must be -unnecesarily- written
Is this only on idiotic Windows System or on Linux too?
Linux is impacted as well it seems per the forums thread.
Also see about:config browser.cache.disk.enable and browser.cache.capacity
why are they not using a transaction logfile for the session? they would just append changes to the session and replay it on restore.
I just run portable Firefox off my secondary, non-ssd harddrive. I don’t notice any performance issues and I try to run only games on my SSD.
Does it flush after every white? Otherwise a lot of this should be mitigated by the OS filesystem cache.
Since you observed lots of cookie data being written: were ads and/or tracking scripts being blocked (in-browser or via proxy or some other solution)?
If not, this might be something interesting to try for comparison purposes.
Related: using Firefox in private mode probably could be a workaround.
The best suggestion is to turn session restore OFF.
about:config
browser.sessionstore.resume_from_crash to FALSE
Not sure I can get the link posted here, so I’ll write out the search: “Firefox on RAM – ArchWiki site:archlinux.org” (via HN).
A few solutions, some slanted toward Linux but can be modified for other OSes. I’m going to experiment with the first option: Relocate cache only to RAM and give it a few MBs to see how this plays out. Session restore = not a big deal for me. I have an older computer (dualCore, older HD) and although I don’t ever see the HD’s LED flashing often (FF is pretty responsive), I don’t like the idea of my older SATA drive over-working.