Entering the Quantum Era—How Firefox got fast again and where it’s going to get faster

Over the past seven months, we’ve been rapidly replacing major parts of the engine, introducing Rust and parts of Servo to Firefox. Plus, we’ve had a browser performance strike force scouring the codebase for performance issues, both obvious and non-obvious.

We call this Project Quantum, and the first general release of the reborn Firefox Quantum comes out tomorrow.

But this doesn’t mean that our work is done. It doesn’t mean that today’s Firefox is as fast and responsive as it’s going to be.

So, let’s look at how Firefox got fast again and where it’s going to get faster.

Laying the foundation with coarse-grained parallelism

To get faster, we needed to take advantage of the way hardware has changed over the past 10 years.

We aren’t the first to do this. Chrome was faster and more responsive than Firefox when it was first introduced. One of the reasons was that the Chrome engineers saw that a change was happening in hardware and they started making better use of that new hardware.

A new style of CPU was becoming popular. These CPUs had multiple cores which meant that they could do tasks independently of each other, but at the same time—in parallel.

This can be tricky though. With parallelism, you can introduce subtle bugs that are hard to see and hard to debug. For example, if two cores need to add 1 to the same number in memory, one is likely to overwrite the other if you don’t take special care.

A pretty straightforward way to avoid these kinds of bugs is just to make sure that the two things you’re working on don’t have to share memory — to split up your program into pretty large tasks that don’t have to cooperate much. This is what coarse-grained parallelism is.

In the browser, it’s pretty easy to find these coarse grains. Have each tab as its own separate bit of work. There’s also the stuff around that webpage—the browser chrome—and that can be handled separately.

This way, the pages can work at their own speed, simultaneously, without blocking each other. If you have a long-running script in a background tab, it doesn’t block work in the foreground tab.

This is the opportunity that the Chrome engineers foresaw. We saw it too, but we had a bumpier path to get there. Since we had an existing code base we needed to plan for how to split up that code base to take advantage of multiple cores.

It took a while, but we got there. With the Electrolysis project, we finally made multiprocess the default for all users. And Quantum has been making our use of coarse-grained parallelism even better with a few other projects.

Electrolysis

Electrolysis laid the groundwork for Project Quantum. It introduced a kind of multi-process architecture similar to the one that Chrome introduced. Because it was such a big change, we introduced it slowly, testing it with small groups of users starting in 2016 before rolling it out to all Firefox users in mid-2017.

Quantum Compositor

Quantum Compositor moved the compositor to its own process. The biggest win here was that it made Firefox more stable. Having a separate process means that if the graphics driver crashes, it won’t crash all of Firefox. But having this separate process also makes Firefox more responsive.

Quantum DOM

Even when you split up the content windows between cores and have a separate main thread for each one, there are still a lot of tasks that main thread needs to do. And some of them are more important than others. For example, responding to a keypress is more important than running garbage collection. Quantum DOM gives us a way to prioritize these tasks. This makes Firefox more responsive. Most of this work has landed, but we still plan to take this further with something called pre-emptive scheduling.

Making best use of the hardware with fine-grained parallelism

When we looked out to the future, though, we need to go further than coarse-grained parallelism.

Coarse-grained parallelism makes better use of the hardware… but it doesn’t make the best use of it. When you split up these web pages across different cores, some of them don’t have work to do. So those cores will sit idle. At the same time, a new page being fired up on a new core takes just as long as it would if the CPU were single core.

It would be great to be able to use all of those cores to process the new page as it’s loading. Then you could get that work done faster.

But with coarse-grained parallelism, you can’t split off any of the work from one core to the other cores. There are no boundaries between the work.

With fine-grained parallelism, you break up this larger task into smaller units that can then be sent to different cores. For example, if you have something like the Pinterest website, you can split up the different pinned items and send those to be processed by different cores.

This doesn’t just help with latency like the coarse-grained parallelism did. It also helps with pure speed. The page loads faster because the work is split up across all the cores. And as you add more cores, your page load keeps getting faster the more cores you add.

So we saw that this was the future, but it wasn’t entirely clear how to get there. Because to make this fine-grained parallelism fast, you usually need to share memory between the cores. But that gives you those data races that I talked about before.

But we knew that the browser had to make this shift, so we started investing in research. We created a language that was free of these data races — Rust. Then we created a browser engine— Servo — that made full use of this fine-grained parallelism. Through that, we proved that this could work and that you could actually have fewer bugs while going faster.

Quantum CSS (aka Stylo)

With Stylo, the work of CSS style computation is fully parallelized across all of the CPU cores. Stylo uses a technique called work stealing to efficiently split up the work between the cores so that they all stay busy. With this, you get a linear speed-up. You divide the time it takes to do CSS style computation by however many cores you have.

Quantum Render (featuring WebRender)

Another part of the hardware that is highly parallelized is the GPU. It has hundreds or thousands of cores. You have to do a lot of planning to make sure these cores stay as busy as they can, though. That’s what WebRender does.

WebRender will land in 2018, and will take advantage of modern GPUs. In the meantime, we’ve also attacked this problem from another angle. The Advanced Layers project modifies Firefox’s existing layer system to support batch rendering. It gives us immediate wins by optimizing Firefox’s current GPU usage patterns.

???

We think other parts of the rendering pipeline can benefit from this kind of fine-grained parallelism, too. Over the coming months, we’ll be taking a closer look to see where else we can use these techniques.

Making sure we keep getting faster and never get slow again

Beyond these major architectural changes that we knew we were going to have to make, a number of performance bugs also just slipped into the code base when we weren’t looking.

So we created another part of Quantum to fix this… basically a browser performance strike force that would find these problems and mobilize teams to fix them.

Quantum Flow

The Quantum Flow team was this strike force. Rather than focusing on overall performance of a particular subsystem, they zero-ed in on some very specific, important use cases — for example, loading your social media feed — and worked across teams to figure out why it was less responsive in Firefox than other browsers.

Quantum Flow brought us lots of big performance wins. Along the way, we also developed tools and processes to make it easier to find and track these types of issues.

So what happens to Quantum Flow now?

We’re taking this process that was so successful—identifying and focusing on one key use case at a time — and turning it into a regular part of our workflow. To do this, we’re improving our tools so we don’t need a strike force of experts to search for the issues, but instead can empower more engineers across the organization to find them.

But there’s one problem with this approach. When we optimize one use case, we could deoptimize another. To prevent this, we’re adding lots of new tracking, including improvements to CI automation running performance tests, telemetry to track what users experience, and regression management inside of bugs. With this, we expect Firefox Quantum to keep getting better.

Tomorrow is just the beginning

Tomorrow is a big day for us at Mozilla. We’ve been driving hard over the past year to make Firefox fast. But it’s also just the beginning.

We’ll be continuously delivering new performance improvements throughout the next year. We look forward to sharing them with you!

Learn the best of web development

I'm okay with Mozilla handling my info as explained in this Privacy Policy.

Thanks! Please check your inbox to confirm your subscription.

If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.

82 comments

bornjre

i developer edition about two weeks ago loved ui but after some time my laptop fan went nuts, i was running only two tabs (one being youtube) and nothing much. it must be sorted out now. excited for new fox :D

I appreciate your dedication and hard work. I was a devoted Firefox user because of the customizability, but I strayed to Chrome and Slimjet for the speed. Now I’m ready to rejoin the Firefox family and as I’ve been promised take advantage of the new speedster on the block. Good Luck!

Well, this is the problem these days. People don’t have principles, they go where is more “warm”.. You stick with a FREE browser that respects your privacy, or you pee on everything for a little speed. You think it was easy defending a country/city/village? Why not invite the enemy, sell your town for a shinny mirror or something …

How much have you donated to Mozilla ?
Privacy is dead because of folks like you. Sorry, it is just the truth, hard.

This is very true. And now thanks to all those people who only care about “speed”, we end up with a Chrome clone with barely a fraction of the good extensions it used to have… Cookie Manager+? Gone. Tamper Data? Gone. RefControl? Gone. TabGroups Manager? Gone. YesScript? Gone. Small Tabs? Gone. All I’m left with is Ghostery, uBlock, and HTTPS Everywhere. Wow, that’s so awesome!

I remember of a time when Firefox was interesting for its extensions. Now it’s just “Chrome with privacy”. Better than nothing, but a lot worse than before, and no other option anyway because of folks like Marty.

I was a true believer and defender of Firefox since the beginning. The GUI was superior and you could modify every setting to your liking. When Google thinks its time to remove the backspace to go back functionality from Chrome (and they did), you are out of luck (except of a few addons).

But then it comes to a point where the use of Firefox becomes unbearable and you have no other choice but to look for alternatives.

Have over 10000 bookmarks like me? If you accidently hover over “Bookmarks” Firefox will be completely stuck for 30 seconds, because it tries to load all bookmarks at once, even though it can only display a fraction.

Have over 500 Tabs open? Impossible on Firefox. Firefox became extremely slow after I opened 20 video tabs. Admittedly, Chrome takes 32GB RAM when I have my 500 Tabs open, but I scale my system to my needs.

The switch was not easy and I lived with those problems for years. Tried switching to Chrome multiple times but it was just shitty. I hated Chrome’s interface and it’s tabbing. I had to heavily rely on addons and got used to it after I got sick about Firefox’ performance. I’ll take a look at Quantum, but I have a feeling that the bookmarks bug is still not fixed.

You’re talking utter nonsense. I used to use Firefox avidly until release after release got slower and slower until it was literally unusable on my machine. At that point I tried Chrome and was pleased to find it was, shock horror, usable. It remained usable (and has led the way with dev tools) and so I continued using it. It was never about Chrome being faster and shinier, it was about Firefox going completely off the rails with it’s obsession with skins and bloated UI.

Quantum has caught my interest and so I am now willing to give Firefox another chance. Sorry if that infringes on your exclusive club. Over time I am sure the addons will return, they’ll just need to make sure they don’t bloat the browser and send it back on the downward spiral it was on for many many years.

The reason we have to focus on speed is because the modern web is a disgusting, bloated mess of javascript, CSS, and redirects. Even now, with _any_ browser, the web is barely usable.
Opera is no longer 3 MB because it’s had to become safer, faster, and the standard technology the web uses has become substantially more inexplicably complicated. All of that takes more code.

Don’t pretend it’s “folks like Marty”. It’s general human behavior. And even if you could change the 6,000,000,000 or so humans that have the same instincts as Marty, by the time you got done, they’d all be dead and there’d be a whole new batch of 12,000,000,000 humans with the same behavior, over again.

And people like you those who discourage others from trying out new things and moving the wheel forward. The chromium project is one of the best things to happen to the tech world in recents years which has laid the path for many cool technologies (v8, nodejs, electron etc.) and is also the best thing to happen to Mozilla/Firefox. Competition always moves the world forward, not the opposite.

… not to mention that Firefox has almost always being faster than Chrome.

Chrome has a faster Javascript engine, but overall performance are not that good, except in benchmark and demo/game. For regular browsing (what you do 95% of the time, if not 99%), Firefox wins, especially when you have many tabs opened. And what about Chrome’s huge memory consumption?

Instead of trusting benchmarks, people should trust their own experience…

I really like Vivaldi’s approach to things, but the “built with the web for the web” way is making things glitch for me in a low end machine, even using more ram than chrome.
It would be really great if they can ditch chromium and go Servo & Rust, so we can combine the customizability with performance
Also I think that Firefox should give customizability and new features more focus

amazing! thanks for putting in the hard work that makes it easier for the rest of us to move away from having our own data sold :) i’ve been using chrome for a long time out of what felt like necessity and and i’m excited to make the switch back to my first love

Performance increase – well done. But what about minor issues that are part of firefox for years and years? One issue was not to delete indexedDB – as soon as media started focussing that topic, you suddenly were able to fix that issue in no time.
An other issue is the parent folder (aka path) in bookmark search. This is an issue which is part of Firefox since more than 10 years ago – and Quantum kills the only workaround (3rd party extensions Go Parent Folder and Show Parent Folder)

It’d be interesting to see whether rendering a page on a GPU is more efficient from a performance per watt perspective than just rendering on a multicore CPU, and is that vendor specific (Nvidia vs. AMD vs. Intel vs. mobile GPU, Mac vs. PC vs. Linux vs iOS vs. Android). What does it do to battery life of a laptop or mobile device when it’s constantly spinning up and down the GPU?

Since about two weeks, I am having problems with typing texts. The characters appear only after some delay and often are scrambled. Especially spaces are moved to the end. But also the caps loc state is kept, resulting in multiple capitals at the start of a new sentense. Even typing a simple password is becoming a problem. Closing and reopening Firefox seems to solve the problem. I only have about five to seven tabs open.

Speed may now be FF’s friend, which is great – just tested and indeed it was slightly faster than Chrome. However, image saturation is nasty. I’m not a dev, but for that reason, for now, I’ll continue to use Chrome.

Lin, what a great article! I clicked through a link from How-to-Geek, but I expected to understand little to nothing, since I am far from being anywhere near a developer. But I did understand it! Amazing! Thank you for the article. I plan to return to Firefox and try it out.

I don’t think this accurately represent how long it took for e10s to be testable.
The first time I’ve seen *actual* e10s was in FirefoxOS when .. Chris Jones? I think? and Guillaume? added the actual process separation (and this was after a lot of ground work had been also already done by several other people). At that time I though it would take off and it felt like a corner stone, though in reality, it really took off later.
A basic sandbox shortly followed and a little later, Desktop Firefox on Linux could use it, granted that you recompiled it, because it used the same code as FirefoxOS.
This was in something like 2014 (I might be off by a bit, was it 2013? I guess hg has the date) and work was already in progress in 2011.

I believe Mozilla started to much more seriously commit resources to this in 2016 though (which is great). So much work by so many people, and I’m happy with how fast this new version is by the way!

What’s the point when nearly all my addons, plugins and extensions are no longer compatible? Almost useless. Mozilla continues to shoot itself in the foot in this regard. Used to be my daily driver years ago. Now … never use it. Tired of Mozilla changing the game every few months.

Is Quantum DOM already intoduced in Firefox 57?
Here’s what I found on ghacks:
>There’s more to come though. Quantum has 5 parts, 4 major ones. Out of these 4 only two are shipped with Firefox 57. A large one, WebRender, is planned for 59. The other missing is Quantum DOM, about which I don’t know enough to tell how big it is when it comes to performance, smoothness and responsiveness matters.

It would also be great to see the graphs for the below stats:
– amount of users switched to FF 57
– amount of people staying at various ESR versions as long as possible (due to XUL supported revoked from FF 57)
– amount of users stopped using FF altogether

According tohttps://arewewebextensionsyet.com/
the overall porting situation is rather sad (partially because of WebExtensions API changing way too often for a stable platform).

way to go for the team @ Firefox!
This is a tremendous effort as harnessing the power of new hardware in such an innovative way is challenging to say the least! cant wait to see my GPU humming and spinning at full utilization!

Been many years since I left the Mozilla fold having come up from Netscape (every version from 3.0 Gold onwards) through whatever version Firefox had six or so years ago. I’m interested but tentative as well. Tomorrow I’ll download the stable version and we’ll see where it takes me. Great write-up by the way.

Better multi-CPU seems a way to go. But not the only.
Focusing on it allows the trend of inefficient code to continue at will.

Personally, I use old PCs to test any application.
Right now using Midori on a 1GHz 686 CPU and 512MB RAM.
What about JAVA? JAVA is to turn off, for several reasons.

Cookies are not the only problem when consulting sites.
Java, and the call to multiple locations not related, is a killer.
Wonder why… We all know why: A tendency to abuse!

All those must be blocked at will, call it as you will.
… As well as ‘rendering’, where not needed.

Shorter code is also a quality many abandoned.
Wonder why… We all know why: A tendency to laziness.
When Opera is no longer a 3Mb application…
… Something is terribly wrong, and Lynx may be the way back.

Thanks a lot, guys. I have been a firefox user since the very beginning and proud to stick with people that really vouch for the freedom of the user. I am so happy to see my browser blazing fast again! :)

I have got my Firefox webbrowser customised exactly how I like it, but now most of those addons will be gone – all for the sake of speed. I loved Firefox for just how much I could customise just about anything I wanted on it.

But now it will become just another Chrome clone.

How far you have fallen!

Ps. will we still be able to change the [background] themes/appearance? I use the Firefox Blue Dots theme everywhere.

Firefox is an old tired dog. It is sloooow. You can’t even type in a text field without it visibly hanging. If I have to use Firefox and have to type more than a single sentence, I’ll open up notepad, type the content there, and then paste it into Firefox, it’s that bad.

And no, this isn’t some “custom plugins” deal: stock Firefox on fresh 48-core servers does it too (it’s the only browser installed on the machine).

I am noticing issues when trying to open a minified JS file in the developer tools. The tab just says “loading…” and never loads. Perhaps this is not a common use case but from time to time I have to do some quick checks even on minified JS. This wasn’t a problem before.

Unlike others, I didn’t forsake FF for Chrome (Chrome is Google, Google is poisonous IMHO). I use FF wherever possible and have donated (too long ago, I’m embarrassed to say). Thank you, guys, for your hard work and determination to keep FF alive for those of us who object to being seen as ‘The Product’. ps. All my Add-Ons appear to have been updated, hooray!

Good article with enough technical depth covering various aspects of the browser. Having to plumb an existing code base to bring in all the changes to work well with modern hardware is a herculean task. Well done and all the best.
The task stealing part reminded me of my work using Intel Threading Building Blocks (https://www.threadingbuildingblocks.org/) back in 2007/08 – Recursive parallelism

Congratulations for the new Firefox! And a big “thank you” for the hard work!

I am just a bit worried because of “old” add-ons. This is the most important unique selling point of Firefox, aside from privacy and open source.
For example: There seems to be not auto-delete for LocalStorage, including a whitelist. All add-ons for this scenario are not working anymore. Developers told me, there is no access to LocalStorage anymore for add-ons.

Thats why we will stick with FirefoxESR until this is solved. And I hope it CAN be solved. Some developers of add-ons told me, that there is no way anymore because of restrictions. I am not a developer, so I just have to believe what I have heard.

Anyway, it looks like Firefox is on a good way! And if the necessary add-ons for improved workflow (search bar) and privacy (LocalStorage, for example) will work again, our company will make the move from ESR back to “normal” Firefox!