20-line patch to Firefox 4 that makes startup on Windows up to 2x as fast

In the world of browser wars, speed is everything. All the top vendors love to show off how fast their browser is and why it is better than the competition. So, when a user comes up with a way to increase the cold boot time of a browser, it generally grabs the attention of many people.

Taras Glek, from bugzilla.mozilla.org, found a way to trick Windows into loading Firefox faster by using a simple patch. From the bugzilla.mozilla.org page via Reddit:

Basic idea is that the sequential flag + bull**** read tricks windows into reading xul in Mb chunks instead of stupid 32k(or smaller) ones. Have to do it this way because there is no fadvise() on Windows(that I know of) A big sequential read cuts down on a lot of seeks.

Many users are reporting faster boot times, with load time cut by 50% on slower drives. If this work-around proves to work for the masses, it may be rolled out in the next version of Firefox. Currently, there are users looking to refine the process to make it even more efficient.

When trying out any experimental technique, you are cautioned to do so at your own risk. This patch has not been verified to work on all versions of Windows, but the general response so far has been very positive.

Report a problem with article
Previous Story

LittleBigPlanet 2: Review

Next Story

No favoritism; new iPhone ad has AT&T and Verizon working together

107 Comments

Commenting is disabled on this article.

Who's using a computer that takes longer than 3 or 4 seconds to load FF? If that's the case you've got bigger issues than how fast your browser opens.

RealFduch said,
Firefox 3.6 and 4.0 use 1.9Gb of RAM (I have 2Gb) on my dual-core PC and starts about 20-30 minutes. Moved to Chrome...

There's something really wrong with your computer then.

Firefox is slow to load, but even on slow netbooks with atoms it shouldn't take more than 10 or 15 seconds.

For me as long as it is an improvement over 3.6.13 is good enough for me... as if +/- 20 seconds boot time is going to make a differnce in my life, last I heard patience was a virtue eheh.
So many applications take 10, 20 or 30 seconds to lauch, it's what you do with them that matters not the amount of time you wait for them to start...

The day I use a browser simply because of it's start/load time, is the day I quit using a browser!!

Even on my 8 technically antique computers, NO browser takes more than a couple seconds to start.

Good news for the geeks that must tweek to the max though!!

Been using Firefox since the Phoenix days, but Firefox4 Beta 9 is seriously pushing me to Google Chrome. The main reason I held out on using Firefox was AdBlockPlus. But Beta 9 is seriously **** on Mac OS X, between dog slow performance and a flickering tab bar, I tried Chrome again for first time since it originally launched, and like it a lot. Especially now ABP is on it.

Mozilla need to sort their **** out.

jasondefaoite said,
Been using Firefox since the Phoenix days, but Firefox4 Beta 9 is seriously pushing me to Google Chrome. The main reason I held out on using Firefox was AdBlockPlus. But Beta 9 is seriously **** on Mac OS X, between dog slow performance and a flickering tab bar, I tried Chrome again for first time since it originally launched, and like it a lot. Especially now ABP is on it.

Mozilla need to sort their **** out.

I keep hearing bad things about Firefox 4, makes me sad. Maybe they should switch to webkit or something, start from the ground up. The old Netscape code needs to be put to rest.

TRC said,
I keep hearing bad things about Firefox 4, makes me sad. Maybe they should switch to webkit or something, start from the ground up. The old Netscape code needs to be put to rest.
Note: webkit is a rendering engine, not a browser. The UI is separate.

Maybe now they should focus on excess memory usage, I can leave chrome running full of tabs with no issues, firefox grinds to a halt, uses 1gb of ram and can't even play flash videos without stuttering

jasonon said,
anybody tried chrome? the start up is half a second... blows my mind

yes,not firebug, not abp, not developer toolbar = useless for me.

Magallanes said,

yes,not firebug, not abp, not developer toolbar = useless for me.

Check the Chrome Settings menu -> Tools -> Developer Tools. Or Firebug Lite Extension. If it doesn't do stuff that you can do on Firebug, though, I can understand.

Not acceptable. I want FF to be so fast I just have to look at my icon and it launches. Come on Mozilla, make it happen or I'm switching to Chrome.

Is launch time really that important? If you can't wait a few seconds for a program to load you have issues. Reminds me of Homer and the barbecued buffalo. "30 seconds? But I want it now!"

well maybe its my opinion but somehow firefox its the most balanced browser, opera its the fasstest but also a cpu hog its the browser with higher cpu usage, and chrome sure it startup very fast but its a memory hog open few tabs and the ram usage of chrome surpass any browser. Anyways firefox its not fast but its not that slow, open ie7 and ie8 on windows xp seems to be slower...

warwagon said,
Just get an SSD drive. Problem solved.

But with this plus an SSD drive, surely Firefox will be loaded before the *click* of the mouse button even reaches your ears right???

warwagon said,
Just get an SSD drive. Problem solved.

I have an SSD and Firefox beta 9 without extensions. It's still the slowest of all the browsers taking more than a second to load, sometimes even 2, while the IE and Chrome load in less than 0.4s. It also takes twice as long as IE9 and Chrome to render sites.

K.John said,

I have an SSD and Firefox beta 9 without extensions. It's still the slowest of all the browsers taking more than a second to load, sometimes even 2, while the IE and Chrome load in less than 0.4s. It also takes twice as long as IE9 and Chrome to render sites.
How do you time a 0.4s start-up? You'd have to be pretty fast on the stop watch!
...(joking - I know it's not with a stop watch)

K.John said,

I have an SSD and Firefox beta 9 without extensions. It's still the slowest of all the browsers taking more than a second to load, sometimes even 2, while the IE and Chrome load in less than 0.4s. It also takes twice as long as IE9 and Chrome to render sites.

0.4s really? what? WOW!, i want an SSD

It isn't a conventional patch, at least like any Windows update kind of patch.
Any way to "install" this? I would really like to try it out, but dont even know where to start with all the compile stuff...

T-1000 said,
It isn't a conventional patch, at least like any Windows update kind of patch.
Any way to "install" this? I would really like to try it out, but dont even know where to start with all the compile stuff...
Just wait for it to land at some point in the next few days and grab a nightly with it included.

manucas said,
NOW?
Now that i just dumped FF 4 beta 9 for rockmelt?

Just in time.

Isn't Rockmelt just Chrome with a bunch of Facebook garbage thrown in?

"...in Mb chunks instead of stupid 32k(or smaller) ones. Have to do it this way because there is no fadvise() on Windows(that I know of) ..."

Wow, really?

A massive lack of understanding, not only in general coding, but especially with regard to Windows development. If the rest of the Firefox team is this incompetent, they might as well just quit now while they have any dignity left at all.

I can't even think of a good analogy of how stupid this is...

Is this their idea of 'cross development'? Instead of general conceptual programming, they are structuring based on posix concepts and then looking for equivalent commands for use on other OSes?

No wonder Firefox is the dog of browsers.

thenetavenger said,
"...in Mb chunks instead of stupid 32k(or smaller) ones. Have to do it this way because there is no fadvise() on Windows(that I know of) ..."

Wow, really?

A massive lack of understanding, not only in general coding, but especially with regard to Windows development. If the rest of the Firefox team is this incompetent, they might as well just quit now while they have any dignity left at all.

I can't even think of a good analogy of how stupid this is...

Is this their idea of 'cross development'? Instead of general conceptual programming, they are structuring based on posix concepts and then looking for equivalent commands for use on other OSes?

No wonder Firefox is the dog of browsers.

Do you have any idea what you are talking about?

The patch is quite a standard method of sequential reads on Windows due to the way it behaves with respect to pages. The comment about fadvise is perfectly valid since in the POSIX world fadvise has the kernel return how it expects to read and cache the pages (no ordering, sequential order, random order, etc) and is a standard method of pre-emptive caching from the kernel.

Pre-emptive caching is a perfectly valid "conceptual programming" technique and the next step is to look for cross-platform implementations. As ANYONE who has done ANY cross-platform development knows there is essentially nothing in the C family, when working with files at a low level, that is cross platform. These come from what are called "system libraries" and are platform specific. You decide on your concept, to preload and pre-empt the cache, and then you look for equivalent implementations in system libraries.

xul.dll was already being paged in using the standard Windows method. This method, however, uses much smaller page chunks (32-64kb typically depending on a number of factors). This patch sets the sequential read flag, forcing it to read sequentially instead of as paged chunks, and then executes a read to force it to be pre-loaded.

I don't understand how this isn't perfect cross-platform development given that they are using equivalent operations on both platforms. Take a look at the patch yourself, it is a perfectly valid method on Windows and the POSIX equivalent is a change in a function call.

It's the idea that is such a large benefit; not the implementation. The implementation is irrelevant and perfectly professional.

You could barely explain the issue and thus I pro-port that your development background is quite thin so until you can do better you're free to move on and spout bs elsewhere.

ascendant123 said,
You could barely explain the issue and thus I pro-port that your development background is quite thin so until you can do better you're free to move on and spout bs elsewhere.
^^ LOLZ!! True dat!

ascendant123 said,

Do you have any idea what you are talking about?

The patch is quite a standard method of sequential reads on Windows due to the way it behaves with respect to pages. The comment about fadvise is perfectly valid since in the POSIX world fadvise has the kernel return how it expects to read and cache the pages (no ordering, sequential order, random order, etc) and is a standard method of pre-emptive caching from the kernel.

Pre-emptive caching is a perfectly valid "conceptual programming" technique and the next step is to look for cross-platform implementations. As ANYONE who has done ANY cross-platform development knows there is essentially nothing in the C family, when working with files at a low level, that is cross platform. These come from what are called "system libraries" and are platform specific. You decide on your concept, to preload and pre-empt the cache, and then you look for equivalent implementations in system libraries.

xul.dll was already being paged in using the standard Windows method. This method, however, uses much smaller page chunks (32-64kb typically depending on a number of factors). This patch sets the sequential read flag, forcing it to read sequentially instead of as paged chunks, and then executes a read to force it to be pre-loaded.

I don't understand how this isn't perfect cross-platform development given that they are using equivalent operations on both platforms. Take a look at the patch yourself, it is a perfectly valid method on Windows and the POSIX equivalent is a change in a function call.

It's the idea that is such a large benefit; not the implementation. The implementation is irrelevant and perfectly professional.

You could barely explain the issue and thus I pro-port that your development background is quite thin so until you can do better you're free to move on and spout bs elsewhere.


Ok, I'm going to try to ignore your personal attacks. However, I must ask, should we submit a resume with every post to validate our credibility?

Forum Resume:
Programming for 25 years - several degrees in computer science, information systems, engineering, physics, and business - designed and wrote code for projects that I know are running on your computer - designed and wrote code for critical systems on the International Space Station...
(Is that good enough so you won't dismiss my comments like I'm just a petulant child?)

---

It is just this simple: You do not design based on an I/O model from a single OS and then adapt from that model. NT is not UNIX and is vastly different just in the abstract of how general I/O works.

This is just an example of an issue they are hitting because they are designing around a SPECIFIC OS model, which has nothing to do with C or even the OS APIs. It is a flawed designed process - PERIOD.

If I were to engineer roads and designed the lane sizes and expected speeds based on golf carts, no matter how much 'correction' I made to the design, a Corvette would be problematic on my roadways.

You simply do not design based on an OS model and then try to mangle the code into other OSes. This creates a lot of problems and leaves no room for optimizations that take advantage of the model and features of a specific OS later in the development process.

It would be just as stupid to design an OpenGL application and purposely remove any GPU thread yield points, as Win7/Vista doesn't need them, and then be surprised the application locks up the GPU on Linux and OS X since they do not have a video model with an OS level GPU scheduler like Windows 7.

It is a bigger picture of how you approach a project and deal with differences, not specifics of this bit of code. This code is important in that it and the comments provided by the developers are indicative of a faulted thinking process of focusing on how UNIX handles I/O and being surprised that Windows NT is different.

Which should be a basic head slapper for most developers, and is why I find your post defending this flawed thinking perplexing.

thenetavenger said,
It is a bigger picture of how you approach a project and deal with differences, not specifics of this bit of code. This code is important in that it and the comments provided by the developers are indicative of a faulted thinking process of focusing on how UNIX handles I/O and being surprised that Windows NT is different.

Which should be a basic head slapper for most developers, and is why I find your post defending this flawed thinking perplexing.

I've abstracted this from your post because it is the least "fluffy" part of your reply. Your analogies are perfectly valid and understandable but I am not sure they are entirely related. I do not know the details of how the rest of the project runs so I will continue to discuss this specific patch.

Sequential managed IO is a perfectly valid conceptual model with unavoidably OS specific implementations. I see nothing in this patch, or surrounding logic, that has any bad design practises. The general goal is to increase load time by linking a library using the most efficient calls available to that system; the method they have used is perfectly valid from a Windows perspective and the problem does not exist in POSIX distributions of Firefox so this is in essence a windows specific patch (which is inevitable since there is no commonality in the IO models, a higher level abstraction may be appropriate, I suppose) made in the Windows specific code.

This particular developer is more familiar with POSIX then he is with Windows and so his quick (not-even-integrated-into-nightlies) hack patch includes a comment that he doesn't know of an equivalent windows method. Again, perfectly valid, as it is FOSS another developer (such as yourself) is welcome to come along with an alternative patch.

I would be curious, with special care taken for specifics and not analogies, how you would approach this or what exactly you see wrong with this patch in particular.

thenetavenger said,
This is just an example of an issue they are hitting because they are designing around a SPECIFIC OS model, which has nothing to do with C or even the OS APIs. It is a flawed designed process - PERIOD.

You completely misinterpreted what Taras said. He said that Windows lacks an easy syscall to tell the OS to read the entire file in, that's all. This has nothing to do with OS models and everything to do with wanting to achieve a particular goal.

sid1337 said,

You completely misinterpreted what Taras said. He said that Windows lacks an easy syscall to tell the OS to read the entire file in, that's all. This has nothing to do with OS models and everything to do with wanting to achieve a particular goal.

Yeah!
"This stupid car lacks rotating pedals that my bicycle has. How the hell can I drive this stupid thing?"

"So, when a user comes up with a way to *increase the cold boot time* of a browser, it generally grabs the attention of many people."

Surely that should be, "decrease the cold boot time"?!?

hslave said,
I'm stumped. How the F do you apply this patch? I'm dying to try it.

Download the source code and compile with the patch included, or wait for it to get integrated into the Firefox nightly builds. It's not a patch in the conventional sense that you can just download and run it .

So he just reading the xul & mozjs files and then immediately closing it.
In effect putting the files into Windows memory cache.

Kind of the same trick Quicktime, Adobe etc. use (at system startup though)

Maybe this trick can be used for all the other files used by firefox.

BTW, How does this effect the memory profile of the application?

figgy said,
BTW, How does this effect the memory profile of the application?

You now only need 2GB RAM to run Firefox smoothly.

Examinus said,

You now only need 2GB RAM to run Firefox smoothly.

Ha ha funny that -.- Firefox 4 runs just fine on one old PCs with only 768mb of ram

Examinus said,

You now only need 2GB RAM to run Firefox smoothly.


bitching about excessive memory usage on FF4 development builds and with god knows how many tabs, Common sense FAIL, try again please

- Kaboose - said,

bitching about excessive memory usage on FF4 development builds and with god knows how many tabs, Common sense FAIL, try again please

Nah.

- Kaboose - said,

bitching about excessive memory usage on FF4 development builds and with god knows how many tabs, Common sense FAIL, try again please
Relax. It was a joke.

Randall_Lind said,
Firefox has always been the slowest browser to open. So any help is nice.

Not all ways it hasn't, 3.6 may have dropped the ball a bit but in the past it was average.

Randall_Lind said,
Firefox has always been the slowest browser to open. So any help is nice.

Try launching IE7 on XP and we'll talk. Better yet, try opening a new tab.

Firefox loading was rather slow in the earlier betas for me (it would freeze for about a minute after it was open), however it's working better now. Still, anything is better than nothing.

Tanshin said,

Try launching IE7 on XP and we'll talk. Better yet, try opening a new tab.

Firefox loading was rather slow in the earlier betas for me (it would freeze for about a minute after it was open), however it's working better now. Still, anything is better than nothing.


When I feel like travelling to the past and using a 10 year old OS and a browser that's soon to be 2 versions old, I'll let you know. The simple truth is that Firefox IS slower at starting up than pretty much all current browsers on a modern operating system.

TCLN Ryster said,
The simple truth is that Firefox IS slower at starting up than pretty much all current browsers on a modern operating system.

You're comparing the start up speed of a browser that is designed as a multi platform product to that of a browser that is *integrated* into the OS?

If you can't see anything wrong with that comparison, well - I guess then there's not much to talk about >_>

Miuku said,

You're comparing the start up speed of a browser that is designed as a multi platform product to that of a browser that is *integrated* into the OS?

You'd have a valid point if not for the fact that Chrome starts up faster than ALL of them, and it's a multi-platform product.

excalpius said,

You'd have a valid point if not for the fact that Chrome starts up faster than ALL of them, and it's a multi-platform product.

I agree. Even without extensions, Firefox start-up time is one of the slowest

TCLN Ryster said,

When I feel like travelling to the past and using a 10 year old OS and a browser that's soon to be 2 versions old, I'll let you know. The simple truth is that Firefox IS slower at starting up than pretty much all current browsers on a modern operating system.

Well that's not fair. He was just responding to your original point which said "Always has been the slowest.", now you say "Is the slowest." You're totally right that it's the slowest now.

EDIT: Unless of course you meant that Firefox has always been the slowest out of the current crop of browsers or something like that, but that would reek of backtracking.

TCLN Ryster said,

When I feel like travelling to the past and using a 10 year old OS and a browser that's soon to be 2 versions old, I'll let you know. The simple truth is that Firefox IS slower at starting up than pretty much all current browsers on a modern operating system.

Considering that IE is already partially loaded in memory before you start it i expect it to load faster than Fiferox.

There's a Firefox addon that partially loads it in memory like ie to make it faster.

Kirkburn said,
Nope, 100% faster would = zero time. If you cut a time by 100%, there's 0% left.

But the guy you're replying to isn't talking about cutting time, but talking about increasing speeds.

There's an important difference, especially if you're about to apply math to it.

Northgrove said,

But the guy you're replying to isn't talking about cutting time, but talking about increasing speeds.

There's an important difference, especially if you're about to apply math to it.

Right. So if it was 0% faster there would be no difference, 50% faster is 1.5x faster, with 100% being 2x as fast.

Kirkburn said,
Nope, 100% faster would = zero time. If you cut a time by 100%, there's 0% left.

faster is speed, not time. distance/time and since the "distance" is a constant (and it can be 1), then usually it can be measured in time but, it is inverse proportional, less time = more fast.

for example: 50mph, 100% faster is 100mph.

Faster is either speed *or* time (I am certainly completing an action faster if I do it in 5 seconds instead of 10). Anyway, I retract the directly comment above, as both ways are valid - the original wording, and the updated wording. Maybe a little ambiguous, but I'll shut up now.

I dunno what the big deal is, Firefox isn't ridiculously slow starting up. It really doesn't bother me. A second or so. Big deal.

OceanMotion said,
I dunno what the big deal is, Firefox isn't ridiculously slow starting up. It really doesn't bother me. A second or so. Big deal.

The main reason firefox was popular at first was because of its light weight and ultra fast loading times (vs mozilla suite at the time).

sagum said,

The main reason firefox was popular at first was because of its light weight and ultra fast loading times (vs mozilla suite at the time).


Man, have times changed.

OceanMotion said,
I dunno what the big deal is, Firefox isn't ridiculously slow starting up. It really doesn't bother me. A second or so. Big deal.

Actually it is. It's the slowest browser when it comes to starting up. IE8, Chrome, Safari and Opera all start up much quicker than Firefox which has become complacent in recent years.

TCLN Ryster said,

Actually it is. It's the slowest browser when it comes to starting up. IE8, Chrome, Safari and Opera all start up much quicker than Firefox which has become complacent in recent years.

Well most of IE is already loaded so it gets to cheat a bit.

sagum said,
The main reason firefox was popular at first was because of its light weight and ultra fast loading times (vs mozilla suite at the time).
Good ol' days, eh?

Northgrove said,

IE is no longer integrated with Windows.

IE will still use shared libraries with the rest of the system, not because Microsoft is cheating, but how they've designed their operation system. Nothing to do with IE integration.

sagum said,

The main reason firefox was popular at first was because of its light weight and ultra fast loading times (vs mozilla suite at the time).

The main reason firefox IS popular wasn't because it was lightweight---far from it (but still better than ie6). It was because people have another choice.

flexkeyboard said,

The main reason firefox IS popular wasn't because it was lightweight---far from it (but still better than ie6). It was because people have another choice.

Well I think it has more to do with how horrible IE6 security was (considering IE6 was the main browser when FF became enormously popular) plus the features (tabbed browsing which wasn't available on IE6) and most of all plug-ins.

Tim Dawg said,
Well I think it has more to do with how horrible IE6 security was (considering IE6 was the main browser when FF became enormously popular) plus the features (tabbed browsing which wasn't available on IE6) and most of all plug-ins.

Not to mention the better web standards support.

Tony. said,

Not to mention the better web standards support.


Forgetting much? IE6 was the most standards-compliant browser at the time of it's release.
And as far as I know when FF was released it had worse standards support than IE6 (not that hard considering it was still very early version).

Co_Co said,
did developers just not know about this?

They were waiting until there was no other way to expand Firefox's features... go ahead and google "If Browsers were women" and see why FF takes its time XD

Co_Co said,
did developers just not know about this?
Many things are obvious in retrospective, doesn't mean anyone was stupid for not noticing.

Many users are reporting faster boot times, up to as much as 50% faster on slower drives

50% faster != 2x faster

what said,

50% faster != 2x faster

It say's "cut by 50% of the load time", not "50%" faster. If the load time was originally 10 seconds, 50% of that would be 5 seconds, which is twice as fast.

Joey H said,

It say's "cut by 50% of the load time", not "50%" faster. If the load time was originally 10 seconds, 50% of that would be 5 seconds, which is twice as fast.

See my quote. The article has been updated. I'm not a complete idiot

what said,
See my quote. The article has been updated. I'm not a complete idiot
50% faster of a time can only be interpreted as 50% less time.

Kirkburn said,
50% faster of a time can only be interpreted as 50% less time.

You really need to read the quote in my original comment before you reply. 50% faster = 150% of the original speed, not 200%.

what said,
You really need to read the quote in my original comment before you reply. 50% faster = 150% of the original speed, not 200%.
What are you talking about? It said faster. Faster can *only* mean time gets reduced, not increased. Where would 150% or 200% come from??

Kirkburn said,
What are you talking about? It said faster. Faster can *only* mean time gets reduced, not increased. Where would 150% or 200% come from??
150% or 200% of the _speed_ would make it 1.5 or 2x as fast, respectively.

Well, the latest nightly boots up super fast for me, yet it runs like crap for about 20 seconds, as though it's still loading something.

Gilly said,
150% or 200% of the _speed_ would make it 1.5 or 2x as fast, respectively.
And 150 or 200 were not mentioned, 'speed' as a rate to be positively multiplied makes less sense in terms of load time (what would you be measuring? something per second?). Point I'm making is, the original wording made sense

Edit: as does the alternative, and saying 2x faster. Anyway, I'll stop also being pedantic now.

Kirkburn said,
50% faster of a time can only be interpreted as 50% less time.

No. 50% faster of a time can also be interpreted as 50% faster of a time.
But it doesn't matter anymore since the article was fixed.

what said,

50% faster != 2x faster

LOL, look what you did.

But seriously, you guys fighting over numbers? You're all wrong, cuz no one cares.

Kirkburn said,
And 150 or 200 were not mentioned, 'speed' as a rate to be positively multiplied makes less sense in terms of load time (what would you be measuring? something per second?). Point I'm making is, the original wording made sense

Edit: as does the alternative, and saying 2x faster. Anyway, I'll stop also being pedantic now.

I'm going to be pedantic because you're talking crap. If you add 50% of something to itself you get 150% of the original value, which is not 200% (which would be double).