Magic patch that halves Windows startup

Internet as of late have been obsessing over magically short patches that improve performance _ times(probably as a result of LKML cgroups patch from a few weeks ago). So my work in bug 627591 got picked up in all kinds of news sources(mostly due to @limi’s manlove). Apparently all that internet fame is good for is getting script-kiddies to upload viruses as bugzilla attachments. Dear Internet, please do not interrupt me in the middle of an investigation.

To crux of the optimization lies in trading waiting for random io for fast sequential IO. Turned out that my patch worked great if windows prefetch wasn’t trying to help (ie firefox ran faster without prefetch on my test systems). With prefetch on, the patch was either a smaller win or a downright loss. When I dug in deeper, it turned that the Windows Prefetch helpfully spends 3-6 seconds doing IO before any Firefox code gets to run. It also doesn’t read in a very clever pattern, resulting in a very small speed up for Firefox, but preventing my exciting optimization.

So I curled up into my defeated fetal position and pondered on how would I prevent Windows Prefetch from being so “helpful”. One way would be to install some crapware to cripple prefetch (kidding!), another way is to do the sequential IO in a separate executable(ala on Unix). This way Windows doesn’t try to do insane amounts of IO before my preloading logic gets to run. This seems to work (see wrapper.exe talk in the bug) and has potential to double Firefox startup times. It’s also ugly as sin, but if that’s what it takes…

So now I need more reports to make sure the executable wrapper approach reliably/significantly speeds up cold(post-reboot) startup. Then we can make a decision on how to integrate this into Firefox. But until we have all the data, please don’t jump to conclusions on what will and wont make Firefox 2x faster.


  1. Hrm… maybe there are ways around it, but separate pre-loaders can be ugly in a way that’s visible to the user (at least in my experience on Windows 7). Pinning to the task bar, for example – if you load Firefox and then pin it, you’ll pin the actual app instead of the loader. If you pin the loader then it will show up with it’s funky name and then disappear as the real app loads.

    But worth trying to do something to workaround Windows, if there’s no other way of speeding things up…

  2. Robert O'Callahan

    I hope you meant “halve” and not “double” 🙂

  3. It sounds like it is a bug in Win’s prefetch. Is MS working on fixing this or have they indicated that they will never fix it?

  4. [I really, really, hope you already know this and this comment is pointless, but it’s not obvious in your post, so…]

    Is this prefetch on XP or Vista/7? The prefetch mechanisms are different (and allegedly much better) in the newer flavours.

    See, e.g. the “superfetch” stuff at

  5. URL says “doubles”… ?

    Anyway, nice news.

  6. Excuse me for asking what may be very obvious but surely Windows has an API flag to disable prefetching? I’ve no experience on this but I would just assume this to be the case. Complete naivety perhaps?

  7. deleting your files from layout.ini in windows prefetch. In the text I mean, maybe it works

  8. Create service fails on Firefox 4.2a1pre, is there going to be an update for this issue?