Hacker News new | past | comments | ask | show | jobs | submit login
20-line patch to Firefox 4 that makes startup on Windows 2x as fast (bugzilla.mozilla.org)
117 points by joshfraser on Jan 23, 2011 | hide | past | favorite | 27 comments



Taras Glek's blog (http://blog.mozilla.com/tglek) contains a lot more information about link optimizations to improve startup times of Firefox.

One of the reasons why loading libxul is so slow normally is that the chain of constructors called at initialization time is arranged backwards in the library (http://blog.mozilla.com/tglek/2010/05/27/startup-backward-co...) so the OS (which is usually optimized for forward loading) cannot efficiently prefetch the pages.

There is also a post that explains how they measure the startup time on Windows (http://blog.mozilla.com/tglek/2010/10/04/diagnosing-slow-sta...) and Unix (http://blog.mozilla.com/tglek/2011/01/14/builtin-startup-mea...).


After using FF for 5 years it got so slow on my Mac that it became unusable. I made the switch to Chrome last year and I'm not looking back. I was an early adopter and supporter (including money) but FF is no longer what it used to be. The code base is bloated, performance is sluggish, they don't seem to care about developers anymore (websql anyone, lack of officially supported debugging tool). All of this in spite of cream-of-the-crop tallent that they have acquired in the last few years. I keep asking mysel and just can't figure: how did it all go so wrong.


> The code base is bloated

Evidence?

> performance is sluggish

In 3.6, right? 4.0 improves on a lot of that.

> websql

Which pretty much everyone developing web browsers and working on the relevant standards now agrees was a bad idea, last I checked (if nothing else because it can't be sanely standardized). Firefox 4 is shipping with IndexedDB, if you note.

> they have acquired in the last few years

And who have been working on Firefox 4. Firefox 3.6 branched from trunk in August 2009...

Yes, the release cycle is too long; that's being fixed.


Well, bloat is somewhat subjective, so "evidence" is hard to come by. I don't know about the other poster's reasons, but I agree, so here are mine. That xulrunner/FF/thunderbird/etc. are built from the same tree is the first indicator. Then there are the multitude of build options, a few pages' worth. The output of these two commands is somewhat telling:

~/src/mozilla-1.9.2$ find -name \.c -o -name \.cpp -o -name \.h -o -name \.idl -o -name \.js -o -name \.xml | grep -v /tests/ | wc -l 11740 ~/src/mozilla-1.9.2$ find -name \.c -o -name \.cpp -o -name \.h -o -name \.idl -o -name \.js -o -name \.xml | grep -v /tests/ | xargs cat | wc -l 4386362

(Painful to construct command lines like that on a phone, and that is a somewhat old version of the tree, but unless FF4 is significantly smaller than 4m lines and doesn't require building xulrunner and FF, the point stands.) The large number of dependencies is another indicator.

I'd be remiss if I didn't mention that FF is still my "workhorse" browser, and I like it a lot, despite the flaws and the bloat. (I've been using Arora for a long time, but it has some stability issues still. I like Luakit, which is small and hackable, but it's kind of a niche browser. I'm not at all a fan of Chrome.)


> That xulrunner/FF/thunderbird/etc. are built from the same tree

xulrunner and Firefox are (since Firefox is a strict superset of xulrunner). Thunderbird pulls in the core code and has a separate tree for the mail-specific stuff.

The line of code count is what it is, but what makes that "bloated"? Have you compared that to any other reasonably full-featured web browser (e.g. not links)? Have you compared the dependencies to any other web browser? I think you're just severely underestimating how much stuff a web browser is expected to do nowadays...

Most of the build options are dead, in fact (as in, if you try to use them, they won't build). There's ongoing work to remove them from the configure script so as not to confuse people.


> That xulrunner/FF/thunderbird/etc are built form the same tree > ... running wc -l on the codebase

These are your "bloat" indicators? That's about as primitive as using SLOC as an indicator for programmer productivity.


It's not a scientific metric; I did preface this by saying that "bloat" is a subjective term. But LOC of the codebase is a pretty good rule-of-thumb metric; I'm not pretending any more credibility than that. It's not hard evidence, but it is an indicator (and I chose the word carefully) that the codebase may be trying to do more than it ought to. It is an indicator in the same way that fatigue and a rash around your joints are indicators that you have strep throat, but the evidence would be the presence of some strain of streptococcus in your blood. There's no line of code that one can point to and say "Hey, that conclusively proves bloat."


WebKit is essentially equal: http://www.ohloh.net/p/WebKit/analyses/latest


There ought to be asterisks before the dots in those two find commands, which have instead turned into italics. My apologies.


FF4 has significantly improved performance, at least. It's much more on par with Chrome and Safari than 3.x.


I think FF needs a way to benchmark extensions.

It's true, without SSD, FF3.X cold-start is not what it should be. However, many users do face an interesting dilema. They complain about slow startup time, and at the same time, call themselfs power-users with 10+ extensions, which makes it hard to switch browsers.

The recent Skype-disaster highlighted the problem of missing extension-benchmarks for the public. I don't know how that could be done, but besides the 5-star ratings, there could be a mozilla-provided performance indicator.

FF4 does improve performance, but power-users will still use the same extensions.


We're working on benchmarking extensions' effect on startup time:

https://bugzilla.mozilla.org/show_bug.cgi?id=623950


(disclosure: I work for Mozilla)

The 2x improvement is for cold startup on specific configurations, mainly on hard drives with slow seek times. For faster hard drives, the improvement is less, and for SSDs it may be much less.

I should also note this is just one of many startup speed improvements coming in Firefox 4.


There are lot of user with slow machines in developing nations. They are typically using a pirated copy of windows xp on a slow hardware and since initially microsoft didn't allow upgrade to IE 7 on pirated copies, lot of people moved to firefox. They would certainly enjoy the fast startup time.And considering that lot of such people are there( it was in the news that Ballmer told Hu that 90 percent of China is using pirated windows) it is still a big win for firefox usuability overall.


Hmmm, so I suspect in practice that you're not going to see this kind of difference usually - since he's probably testing on a binary he just built, SuperFetch (the built in OS prefetcher) hasn't had a chance to determine what pages are usually used by Firefox. Once you've used FF as your browser for awhile, SuperFetch will know better and won't do as badly.

That being said, this trick will probably beat SuperFetch, since they know up front that they'll be using big chunks of xul.dll. Don't do this in every app though, or else every app in the system is just chewing through IOs on pages they might not actually be using.


SuperFetch only hits the first 10 meg of a DLL. If any of these are larger than that, you'll still see significant thrashing on pages located further back in the binaries. I implemented a similar solution for chrome.dll last summer and it had a gigantic effect on cold start times. Glad to see Mozilla prioritizing startup too.


>SuperFetch only hits the first 10 meg of a DLL. If any of these are larger than that, you'll still see significant thrashing on pages located further back in the binaries

Yuck. Is there a good engineering reason for this reliance on the physical location of code within a lib file rather than its logical internal structure? I guess its a compromise they made after running some studies. Still seems sickeningly ugly though. Just like the trick the OP was forced to implement to override this behaviour.

Yucketty yuck yuck.


Define "logical internal structure"? Most code in a library won't be differentiated by use unless you can provide WPO or PGO-based feedback that you trust as representative. As for the next obvious question ("why not just read in the whole thing?"), I think you can probably guess.

I'm not sure how yucky this is. The world is analog. MSFT made things go faster without asking developers to change anything they were doing. I wish more OSes showed more of this sort of user-centric, data-driven prioritization of feature development.


I am clearly much less qualified to speak on this subject than you so I defer to you on this one.

All I meant by 'yuck' was that in my limited experience with computer science, whenever there is a solution that involves as blunt a compromise as 'cache the first 10 megabytes,' it isn't usually too long before that solution is known as the 'naive' solution.


Alex, can you link the bug(s) or patch set for your similar changes?




Interesting. I've worked on SuperFetch and I didn't know that!


It's likely that my understanding of the situation is at least partially confused. The "SuperFetch" branding covers a lot of systems with some observably complex interactions. From my recollection of the XPerf traces, we saw misses 10+ MB back in the DLLs and just ascribed it to "SuperFetch" on the front half.

If you could tell me if that's causal, it'd be awesome = )


No, it won't have a big effect on warm or OS-optimized startup time... but cold startup time, especially for new releases, is a big area of concern, so it's nice to see wins there!


While I doubt my specific hypothetical case will actually exist... I think it should also help if the OS has decided not to prefetch the dll for you for some reason. I don't believe it should ever actually hurt but should make it a lot nicer on any of the possible edge cases.


Pretty please put this in Firefox 3.6.15 as well because it will be quite some time before many power-users can upgrade to 4.0




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: