Firefox writes megabytes of data per minute to disk, why?

27

9

iotop -a (accumulated I/O) on Linux shows after about 10 min. of browsing Internet:

Total DISK READ:       0.00 B/s | Total DISK WRITE:       0.00 B/s               
  TID  PRIO  USER     DISK READ DISK WRITE>  SWAPIN      IO    COMMAND           
17330 be/4 wojdyr     1540.00 K     38.48 M  0.00 %  0.00 % firefox              
  403 be/3 root          0.00 B     31.65 M  0.00 %  0.06 % [jbd2/sda5-8]        
17276 be/4 wojdyr      800.00 K     31.06 M  0.00 %  0.00 % firefox              
17329 be/4 wojdyr        0.00 B     20.96 M  0.00 %  0.00 % firefox              
31896 idle wojdyr        0.00 B   1200.00 K  0.00 %  0.00 % virtuoso-~.ini +wait 
31924 be/4 wojdyr        0.00 B   1064.00 K  0.00 %  0.00 % akonadi_n~ail_feeder 
18959 be/4 wojdyr        0.00 B    796.00 K  0.00 %  0.01 % firefox

I'm quite surprised by the amount of data written to disk. I turned off to-disk caching, but it didn't make notable difference. I turned off block-reported-attack-sites/web-forgeries -- nothing changed.

Is this rate of writing to disk normal in Firefox (10.0.1)? It quickly exceeds the total size of my firefox profile.

Looking at modification times of files in the firefox profile I see that a few files are modified very often:

cookies.sqlite{-wal,-shm}
sessionstore.js
places.sqlite{-wal,-shm}
permissions.sqlite

Is there something wrong with my system or configuration, or is it typical for FF?

I don't like this pointless writing to (SSD) disk. Can I do something about it?

EDIT: I've found this guide how to relocate the entire Firefox profile to RAM. It reduced almost to zero data written by firefox during session. (I know this is a bit paranoid and probably not worth the hassle.)

marcin

Posted 2012-03-11T13:22:20.857

Reputation: 403

I know this is an old question but it's what came up when I googled. For me, I found that the Web Of Trust (WOT 20150708) add-on for Firefox was writing to disk 38.8 KB every second. So I disabled the add-on. – Luigi Plinge – 2015-07-13T21:53:20.293

ServeTheHome also discovered this issue recently: http://www.servethehome.com/firefox-is-eating-your-ssd-here-is-how-to-fix-it/

– bwDraco – 2016-09-24T15:10:41.020

2@surfasb "Unless it is a first gen SSD, your laptop will die before the SSD does."

Now it is the opposite - the new TLC based SSDs have much shorter life than old ones with MLC and especially than these with SLC NAND. – ggurov – 2016-12-01T10:56:59.520

7I think you are too concerned with the write limit of SSDs. Unless it is a first gen SSD, your laptop will die before the SSD does. – surfasb – 2012-03-11T19:06:23.860

You are right. I know I there is no reason to worry so much about this disk, but I can't help it :-) – marcin – 2012-03-12T17:41:19.567

Answers

19

I did an investigation of where writes to my SSD come from. I found the same thing you did. After analyzing logs of writes as well as thinking about things I realized that it is Firefox's crash recovery. In order to be able to recover from a crash Firefox has to write the session to disk. The session information is stored in the four files you listed. Firefox updates these every ~30 seconds. With lots of tabs in a big session this adds up to a few GB per day.

But as surfasb says, it is not really anything to worry about.

Mr Alpha

Posted 2012-03-11T13:22:20.857

Reputation: 6 391

Note that these excessive writes are definitely something to worry about if you've got an SSD. – Pointy – 2016-09-23T17:31:16.557

1Not really. If Firefox does 10GB of writes in a day, that still only adds up to 36TB of sequential writes in a decade. Even if its such a low end SSD that 36TG sequential writes were a problem, in a decade something else will probably have had the time to die first. – Mr Alpha – 2016-09-24T13:12:41.597

Actually most of the new SSD are with TLC NAND and their life is much shorter than before. For example, according to Samsung's charts for some mass market 240 GB models writing capacity is as low as 70 - 75 TB. If one keeps all time two launched browsers (Firefox and Chrome clone), these browsers alone can eat all such terabytes even if they are in minimized state all time! Plus the OS virtual memory writes etc.etc. - 70 TB is not so much. – ggurov – 2016-12-01T10:49:24.207

2Those 70-75 TB numbers are related to the warranty, meaning you can't replace it under warranty if you've exceeded that number of writes. It does not mean the drive will wear out and die at that point, no more then that the drive would die after 3 years just because it has a 3 year warranty. As is generally the case with warranties, they are quite conservative. – Mr Alpha – 2016-12-02T15:15:11.880

1Thanks! good analysis. Do you know if it's possible to change the frequency of disk writing? Every 30 seconds seems rather too often for me – marcin – 2012-03-12T21:40:56.727

5In about:config there is a setting called browser.sessionstore.interval. Interestingly according to it Firefox should store every 15 sec. This was not the interval I observed. – Mr Alpha – 2012-03-13T05:59:22.310

24

There is a setting in Firefox that controls how often the session restore saves files. Go to about:config and change:

  • browser.sessionstore.interval to change how often the session is saved. On my system, the default was 15000 (milliseconds) so it was writing to disk every 15 seconds. If you increase this to 300000, it will only write every 5 minutes.

  • browser.sessionstore.enabled can be turned to false to disable this feature completely. This will reduce the amount of disk writes Firefox does, but this will also prevent Firefox from restoring your session when it crashes.

prunge

Posted 2012-03-11T13:22:20.857

Reputation: 758

On my RHEL 7, firefox pushed up my load to 6, but it does not contribute much on CPU usage. So it should be the I/O that consume that. This solution actually reduce the I/O traffic thus make Firefox usable again. – Ding-Yi Chen – 2016-03-04T00:49:03.240

3

After loading about 10 pages and some in Chrome mine looks like this:

iotop -a output

So I guess that's normal swap/page file use.

(Although one would think with me only using 31% of RAM it wouldn't swap at all.)

conspiritech

Posted 2012-03-11T13:22:20.857

Reputation: 389

Thanks for testing! I doesn't look like swapping, apparently firefox if forcing writing some files to disk as often as possible rather than keeping them in memory. – marcin – 2012-03-12T17:38:01.350

1

FF was writing to disk constantly at 2.5+ MB/s! I ran sudo iosnoop -p PID and found that the Evernote Web Clipper was doing all the writing. I removed it and disk writes went down to 0 to a few kb/s.

hmj6jmh

Posted 2012-03-11T13:22:20.857

Reputation: 371

sorry for the probably silly question but, was the FF process (via the Evernote addon), or the Evernote process itself which was saturating your I/O? In the first case, how iosnoop was able to detect it? I have never used the tool but I thought it traced the I/O of processes, and could not distinguish Firefox own usage from an extension running in Firefox. – Antonio – 2019-04-16T13:28:55.110

-1

It is perfectly normal for a browser to store changes to cookies and sessions to the disk. The data about which tabs you had open has to be kept somewhere. Your usr directory (I assume that is where Firefox stores those things) shouldn't be located on an SSD to begin with, move it to an HDD.

kotekzot

Posted 2012-03-11T13:22:20.857

Reputation: 849

The problem is with large amount of written data, several orders of magnitude more than what is needed to store cookies or open tabs. Regarding HDD, I have only SSD. – marcin – 2012-03-11T13:52:36.297

Is it a laptop or a similar device? Using a pure SSD setup isn't very efficient, so if you could help it I'd advise getting an HDD to store volatile files. I suppose it's possible that there's something wrong with your FF, but I doubt it would be easy to diagnose with the data we have. Have you tried backing up your FF profile and doing a clean install? – kotekzot – 2012-03-11T13:59:30.873

3I don't see how not using SSD is supposed to help. If the file is accessed frequently it's perfectly fine and even recommended to keep it on SSD. I can understand storing movies/photos on HDD since the time/speed isn't that important here but since the files are accessed frequently it should be stored where it is. If you would put this in your answer I would -1 it. The answer itself is good, just the comment not really something to relay on. – MadBoy – 2012-03-11T16:51:47.507

@MadBoy It shouldn't matter much for overall speed if these files are located on an HDD, but it will do wonders for SSD longevity. – kotekzot – 2012-03-11T16:55:21.543

2kotekzot - "it will do wonders for SSD longevity" - any resource to support your claim? I would say that storing sessions on SSD is much better because it is fast and doesn't make neverending noise / is not annoying. – Tomas – 2013-07-23T14:43:53.473

-1

Perhaps someone has a compromised the machine and is using it for anonymous P2P or F2F networking with obfuscated and encrypted filesystems? Like:

https://en.wikipedia.org/wiki/I2P

or

https://en.wikipedia.org/wiki/Darknet_(file_sharing)

https://en.wikipedia.org/wiki/Botnet

conspiritech

Posted 2012-03-11T13:22:20.857

Reputation: 389

1that's probably not this, but thanks for trying to help, -1 was not by me :) – marcin – 2012-03-12T17:44:09.877

i probablyy made too many assumptions anyway, but I guess one shouldn't suggest disaster without testing first. and i forgot how big images and stuff on web pages can be. – conspiritech – 2012-03-13T03:42:21.993

they may do that because they don't want to take up RAM when you decide to start up photoshop or something, and its impractical/not allowed to write rules around it, at a guess. – conspiritech – 2012-03-13T03:44:28.483