Pages

July 24, 2017

Change how many processes multi-process Firefox uses

Mozilla will enable its multi-process architecture this year in the Firefox Stable web browser. The organization runs tests currently on Firefox's Beta channel, and provided that those don't result in major stopper bugs, will release the first version of Electrolysis (e10s) when Firefox Stable hits version 46.
This multi-process version won't ship with all features and improvements that Mozilla plans to add to it. There will be only one content process for instance initially with e10s enabled in the Firefox browser.
This means that websites will share that process for their data, which is different to how browsers that are based on Chromium handle this as they launch a new process for every page open in the browser and also for plugins.

Changing Firefox's multi-process content processes

Firefox would not be Firefox if there would not be an option to play around with different content process values.


firefox content processes


While Firefox will ship with one content process initially, nothing is keeping users from increasing that limit to use more than one content process.
Each content process is listed as Plugin Container for "Firefox version" in the operating system's task manager. The file name is listed as plugin-container.exe on Windows.
Firefox runs as many content processes as you see listed there, provided that multi-process use is enabled in the browser.


dom.ipc.processCount


dom.ipc.processCount


It is rather easy to change the number of content processes. Here is how it is done:
  1. Type about:config in Firefox's address bar and hit enter.
  2. Confirm you will be careful if a warning appears.
  3. Search for the preference dom.ipc.processCount.
  4. Double-click on it and change its value. The default value is 1, indicating that one content process is used.
  5. Restart Firefox afterwards. Easiest way to do that is Shift-F2, type restart, hit enter.
Firefox will use the selected number of content process after the restart.
Please note that it will use more memory when you increase the number of content processes in multi-process Firefox, and less memory if you reduce the number.
Mozilla ran some memory benchmarks recently and found out that multi-process Firefox will use between 10% to 20% more memory initially with one content process enabled, and about double the memory with 8 content processes.
This is probably one of the main reasons why Mozilla will launch the multi-process architecture with one content process initially.
Ideally, from a stability and security point of view, you'd separate each tab, plugin and the browser UI individually.


Source: https://www.ghacks.net/2016/02/15/change-how-many-processes-multi-process-firefox-uses/

July 8, 2017

Firefox 54-The search for the Goldilocks browser and why Firefox might be “just right” for you

Multi-process Firefox is fast like other browsers, but won’t suck up memory and slow down your computer as Chrome will sometimes do.


Today Mozilla is releasing a new version of Firefox that runs using a multi-process architecture, for the first time using several separate processes for your web page content (your tabs).

Now, you might know that some other browsers have done this sort of thing for a while. But even if you think you know everything about multi-process browsers, or if you don’t have the first clue, read on.

In this post I’ll explain what it means for Firefox to run with a multi-process architecture. I’ll also explore how and why Firefox’s approach to running with multiple processes is a bit different from — and often better than — other browsers’.

As I considered how to explain something pretty technical, I thought about a story I frequently read to my daughter Sara: Goldilocks and the Three Bears.





How the Goldilocks principle manifests in web browsers


Much as astronomers search for a Goldilocks planet with life, Mozilla strives to build the Goldilocks browser. In my view, none of today’s browsers strikes the “just right” balance between speed and memory usage.

Your browser’s use of memory impacts your experience both with the browser, and with the other apps that you’re running on your computer. If a browser uses too much memory, your computer may not have enough left to the run the other apps you want to use. In fact, your computer may slow to a crawl if you try to do too much.

Conversely, if a browser doesn’t use much memory, it might not be doing some of the things that it could to make your browsing experience fast and fluid. The Goldilocks principle suggests that the “just right” browser is one that uses a moderate amount of memory — enough to run quickly, but not so much it exhausts your computer’s resources.









Your web browser often consumes more memory than any other app.
If it uses too much memory, you might run out, and your whole computer will slow down.

An app’s ingredients

“Mama Bear’s Porridge” combines two ingredients: oats and powdered milk. Apps have ingredients, too: processes and threads.
When you launch an app, it starts a process. This process can start many threads of execution, each of which shares the same working memory. Processes commonly utilize threads to handle different types of work that need to run at different levels of priority. For example, one high-priority thread may draw the program’s user interface. So the browser knows this and will respond instantly to mouse clicks or typing on a keyboard. Another thread may crunch data in the background at lower priority. To see the processes running on your computer, open your Task Manager (Windows) or Activity Monitor (macOS).
Sometimes, instead of starting a new thread to accomplish a task, an app’s process will start another process for that work. This makes sense for tasks that requires a lot more memory and computing power, or for work that’s better off isolated for security or stability reasons.
Most apps run in a single process, often using multiple threads. But web browsers are not like most apps.






Most apps use one process to run many threads, but browsers work best with multiple procesess.
 
 
 

Warm and tasty: the multi-process browser for the modern web

After launching Firefox in 2004, Mozilla and its community continued to push the web’s capabilities forward. Slowly but surely, the web became a platform, not just for static documents, but for interactive apps like email, word processing, and social networking.
Welcome to Web 2.0!
While this new era of the web was wonderful, Firefox and other browsers couldn’t run multiple web apps simultaneously nearly as fast as the operating system could run native apps. The solution? The browser itself needed to work more like an operating system, juggling several web apps using multiple processes.
With a multi-process architecture, you could use seamlessly a web page in one tab, while pages in other tabs might still be busy crunching. While Mozilla’s engineers knew that this new multi-process approach was possible, adapting Firefox to run in multiple processes would require breaking Firefox Add-Ons that depended on a single-process architecture. Mozilla was reluctant to do this because customizing Firefox through Add-Ons has always been very popular. My former colleagues who created Chrome deserve credit for building it as a multi-process browser.

 

Enter Electrolysis: Mozilla’s project to split Firefox into multiple processes

It was a long road to establish how Firefox should support Add-Ons that would live in harmony with a multi-process architecture. Ultimately, Mozilla committed to two related projects: (1) Electrolysis, an effort to split Firefox into multiple processes, and (2) the transition from traditional Add-Ons to cross-browser WebExtensions. Both initiatives have been huge engineering efforts.
In August 2016, Mozilla launched the first phase of Electrolysis by splitting Firefox to run its user interface and web page content (the pages in your tabs) in two separate processes. Today Firefox is shipping the next big phase of Electrolysis, significantly expanding the number of processes Firefox uses for processing and securing web page content, and enhancing the management of those processes to improve memory use, performance, and stability. These additional processes can potentially run across multiple computing cores, so it’s much less likely for web pages to negatively impact each other or the performance of the web browser in general. And, if a content process crashes, it should not affect other content processes and the web pages displaying in them.
The upshot of these changes is that Firefox is now faster and more stable than ever.

 

Why Chrome gets too hot when Firefox does not

While both Firefox and Chrome now run using multiple processes, Firefox does some things differently to avoid using up your computer’s limited memory.
By default, Chrome creates a separate content process for each instance of a site that you visit. Open 10 different tabs with 10 sites in Chrome, and you’ll have 10 different processes. Each of those processes has its own memory — with their own instance of the browser’s engine. One open tab in Chrome typically consumes hundreds of megabytes of RAM. Chrome’s liberal approach to creating processes can lead to very high memory usage.
On the other hand, Firefox’s more conservative approach to using processes often results in Firefox using less memory than Chrome. By default, Firefox now creates up to 4 separate processes for web page content. So, your first 4 tabs each use those 4 processes, and additional tabs run using threads within those processes. Multiple tabs within a process share the browser engine that already exists in memory, instead of each creating their own.









Chrome uses a separate content process and engine for each website instance,
but Firefox reuses processes and engines to limit memory usage.



Comparing Firefox’s memory usage with other browsers’

Firefox uses 4 content processes because it’s the “just right” number for many Firefox users. With 4 content processes, your computer should have plenty of memory left to run apps besides Firefox.
In tests comparing Firefox’s memory usage with other browsers’, here’s what Mozilla found for various operating systems:
  • Windows 10 — Chrome used 1.77X memory as Firefox (64-bit), and 2.44X as Firefox (32-bit)
  • macOS — Chrome used 1.36X memory as Firefox (64-bit)
  • Linux — Chrome used 1.42X memory as Firefox (64-bit)
    Firefox uses less memory than other browsers.



    Especially if you’re using a laptop with 8GB of memory or less, you’re going to want to think consciously about which web browser you use. Firefox’s considerate usage of your computer’s memory means you can browse the web freely, while still doing the other things you need to do with your computer.

    If you have more than 8GB of RAM, you might want to bump up the number of content processes that Firefox uses. This makes Firefox even faster, although it will use additional memory. To change the number of content processes FIrefox uses, enter about:config in your address bar, and adjust the number for the dom.ipc.processCount setting (we’ll be exposing a visible preference for this in an upcoming release).

    Firefox’s new multi-process architecture is a major step forward, and strikes an excellent balance between speed and memory usage for many people.

     

     

    Project Quantum: cooking up the “just right” browser for modern computing


    As proud as Mozilla is of today’s launch, its position is that no browser, including Firefox, is truly “just right” for modern computers — at least not quite yet. So much has changed inside of today’s devices, and no browser has evolved to take full advantage of multi-core CPUs and GPUs. So, while Electrolysis splits Firefox to run in multiple processes, Mozilla’s other big project, Quantum, is optimizing the browser engine that runs within a content process.

    With Quantum, Mozilla is building breakthrough enhancements to advance Firefox in unique ways. As part of the project, Mozilla engineers are using Rust to code super-fast parallel algorithms that would be incredibly difficult to code safely with C++. With these algorithms, major pieces of Firefox’s engine (e.g. CSS styling), will run in parallel across multiple CPU cores, instead of sequentially on one core. Also as part of Quantum, Firefox will utilize threads to focus computing power and your network connection on the tabs you’re actively using. Firefox will get much faster, while still being respectful of your memory and your needs.

    I hope that you enjoy today’s Firefox release and that you stay tuned for the Quantum leap ahead. Mozilla’s goal is to make Firefox the “just right” browser for every computer, for everyone.


    Source: https://medium.com/mozilla-tech/the-search-for-the-goldilocks-browser-and-why-firefox-may-be-just-right-for-you-1f520506aa35