Firefox 7: Cheating the Operating System to Start Faster

Firefox 7 features improved startup speed. Our research has shown that most OSes are not capable of starting large programs efficiently (see my older blog entries). As a result, Firefox 7 will explicitly tell the OS to aggressively preload our xul.dll/libxul.so/XUL library before passing it on to the runtime linker. This marks the productization of the approach explored in “20-line patch that doubles Firefox startup” that got people so excited. See bug 552864 and dependent bugs for exciting technical details.

Do Not Try this at Home: Ugly Windows

Note: Windows Prefetch does everything possible to thwart exciting startup optimizations. Above optimization only works when prefetch is disabled/broken (ie Firefox should be faster with Windows Prefetch off). See this comment on disabling prefetch for Firefox. Alternatively one may get Windows Prefetch to not slow down Firefox startup by the following magic incantation:

  1. Install Firefox (or delete the windows prefetch entry for existing Firefox 7)
  2. Reboot (Do not start Firefox after installation!)
  3. Start Firefox.

Above helps populate the Windows Prefetch in a less counter-productive way. Explanation: on warm startup Windows Prefetch records irrelevant IO operations and blocks Firefox startup to preload files that Firefox accesses after startup.

Note: the heuristic that we use to detect Windows Prefetch will also prevent this optimization from kicking in on some exceptionally slow hard drives when prefetch is off. This is unfortunate as this optimization is most dramatic on exceptionally slow machines.

According to our preliminary telemetry data, less than 25% of our Windows users have Windows Prefetch off and can benefit from vastly improved startup. We expect to improve this in future Firefox releases by scheduling a prefetch cleanup operation similar to the script in above bugzilla comment.

Operating systems without counter-productive startup heuristics (ie Mac/Linux) will simply allow Firefox 7 to start faster.

14 comments

  1. Maybe I need more coffee, but I don’t see your recommendations for Windows users.

  2. Taras,

    To make Chrome load faster on Windows, has the Chrome dev team made changes to disable Prefetch?

    Thanks,
    Manoj

  3. @Manoj
    good question…
    We now come up with same level js speed,a very similar UI to chrome, but chrome still win a hell way in startup time, even we tweak here and there try boosting firefox up a bit.

  4. @Manoj they have not. On the machines with worst firefox startup chrome also starts up slowly.

    There cases where Chrome still starts faster than Firefox and we are working on fixing them. There are also cases where Firefox starts faster :)

  5. I stop reading your article at the second sentence. That is exactly why firefox is losing its cool. It’s becoming too large for ALL OSes (what other OSes am I not aware of that ff load faster?)

    The Mozilla team like to blame everything on everybody else except their ancient code base. I don’t see the IE9 and Chrome having problem with cold boot and I don’t see them complaining about superfetch (it’s a function of windows for a reason). What I see is IE9 and Chrome solved their boot time and Mozilla complains about it.

  6. Tomas, actually chrome binary footprint is bigger than firefox now. They face the exact same problems. Every modern browser is roughly the same size(huge) because the web is complex. We are actually collaborating with Chrome folks on some of these issues that can be fixed at OS/toolchain level.

  7. maybe it is true that all browsers are getting huge. In fact, this give me the impression that the startup time is not necessary relative to it size, otherwise, it dones’t make sense Chrome load a bigger footprint in less time.

  8. I’m confused. I run Aurora, currently version 8.0a2 (2011-09-21) on Windows XP. Windows Prefetch is enabled on my machine as I asumme it is on most Windows machines, by default.

    A free software program for viewing and removing Windows .pf (Prefetch) files, that is easy to use, is available here:

    http://www.nirsoft.net/utils/win_prefetch_view.html

    Using that program I deleted the Firefox*.pf file. Will that enable me to take advantage of the code made available in FF7 Taras?

    If not, does the install and reboot before starting trick work for user’s have already had Firefox installed, like me?

  9. I’m trying to understand:
    1.if I use the vbscript from bugzilla I improve the performance, and with the new patch firefox will become even faster.

    2.is too slow 5400rpm for the heuristic or you mean something really really slow?

    3.if prefetch is working normally, your patch stop working, make faster or make slower?

    Sorry but I want to accelerate firefox a little on my netbook…

  10. a little off topic:

    What about this: I’ve placed this link into my autostart folder.

    “C:\Program Files\Mozilla Firefox\firefox.exe” -silent

    Firefox is loaded (perhaps with all/many/some dlls, don’t know), and immediately stopped; So the first user-initiated-start of Firefox is os-wise the second one (and perhaps a little faster).

    what do you think?

  11. Updating Firefox made it impossible to use this tip, because it restarted Firefox automatically. Very clever :(

    Is there another way?

  12. @AV,

    1. FF7 + Vbscript should result in a perf boost. Use about:startup extension to verify. Never accept performance improvements without verifying they apply to you :)
    2. 5400rpm is just an example of slow hw. Heuristic uses a windows api to count number of io operations
    3. Prefetch will likely make firefox slower, unless you follow the above instructions on clearing it + restarting computer, then it might be faster

    @patlecat, clearing prefetch manually + reboot is the other way

  13. so if firefox know of this problem why don’t they include the fix in one of their many security upgrades?
    I am getting more and more interested in going to another browser since trying 7

  14. Firefox is degrading in terms of speed day by day, I am using Chrome now. It is much better