Quick background
With the e10s project full steam ahead, likely to be enabled for many users in mid-2016, it seemed like a good time to measure the memory overhead of switching Firefox from a single-process architecture to a multi-process architecture. The concern here is simple: the more processes we have, the more memory we use. Starting Q4-2015 I began setting up a test to measure the memory usage of Firefox with a variable amount of content processes.
Methodology
For the test I used a slightly modified version of the AWSY framework that I maintain for areweslimyet.com. This test runs through a sample pageset, the same one used in Talos perf testing, in an attempt to simulate a long-lived session.
The steps:
- Open Firefox configured to use N content processes.
- Measure memory usage.
- Open 100 urls in 30 tabs, cycling through tabs once 30 are opened. Wait 10 seconds per tab.
- Measure memory usage.
- Close all tabs.
- Measure memory usage.
For this test I performed two iterations of this, reporting the startup memory usage from the first and the end of test memory usage (TabsOpen, TabsClosed) for the second.
Note: Just summing the total memory usage of each Firefox process is not a useful metric as it will include memory shared between the main process and the content processes. For a more realistic baseline I chose to use a combination of RSS and USS (aka unique set size, private working bytes):
total_memory = RSS(parent_process) + sum(USS(content_processes))
For example if we had:
Process | RSS | USS |
---|---|---|
parent | 100 | 50 |
content_1 | 90 | 30 |
content_2 | 95 | 40 |
total_memory = 100 + 30 + 40
Results
Note on memory checkpoints:
Settled
: 30 seconds have passed since previous checkpoint.ForceGC
: We manually invoked garbage collection.- We list the memory usage for each checkpoint using 0, 1, 2, 4, 8 content processes.
Linux, 64-bit
0 | 1 | 2 | 4 | 8 | |
---|---|---|---|---|---|
Start | 190 MiB | 232 MiB | 223 MiB | 223 MiB | 229 MiB |
StartSettled | 173 MiB | 219 MiB | 216 MiB | 219 MiB | 213 MiB |
TabsOpen | 457 MiB | 544 MiB | 586 MiB | 714 MiB | 871 MiB |
TabsOpenSettled | 448 MiB | 542 MiB | 582 MiB | 696 MiB | 872 MiB |
TabsOpenForceGC | 415 MiB | 510 MiB | 560 MiB | 670 MiB | 820 MiB |
TabsClosed | 386 MiB | 507 MiB | 401 MiB | 381 MiB | 381 MiB |
TabsClosedSettled | 264 MiB | 359 MiB | 325 MiB | 308 MiB | 303 MiB |
TabsClosedForceGC | 242 MiB | 322 MiB | 304 MiB | 285 MiB | 281 MiB |
Windows 7, 64-bit
32-bit Firefox
0 | 1 | 2 | 4 | 8 | |
---|---|---|---|---|---|
Start | 172 MiB | 212 MiB | 207 MiB | 204 MiB | 213 MiB |
StartSettled | 194 MiB | 236 MiB | 234 MiB | 232 MiB | 234 MiB |
TabsOpen | 461 MiB | 537 MiB | 631 MiB | 800 MiB | 1,099 MiB |
TabsOpenSettled | 463 MiB | 535 MiB | 635 MiB | 808 MiB | 1,108 MiB |
TabsOpenForceGC | 447 MiB | 514 MiB | 593 MiB | 737 MiB | 990 MiB |
TabsClosed | 429 MiB | 512 MiB | 435 MiB | 333 MiB | 347 MiB |
TabsClosedSettled | 356 MiB | 427 MiB | 379 MiB | 302 MiB | 306 MiB |
TabsClosedForceGC | 342 MiB | 392 MiB | 360 MiB | 297 MiB | 295 MiB |
64-bit Firefox
0 | 1 | 2 | 4 | 8 | |
---|---|---|---|---|---|
Start | 245 MiB | 276 MiB | 275 MiB | 279 MiB | 295 MiB |
StartSettled | 236 MiB | 290 MiB | 287 MiB | 288 MiB | 289 MiB |
TabsOpen | 618 MiB | 699 MiB | 805 MiB | 1061 MiB | 1334 MiB |
TabsOpenSettled | 625 MiB | 690 MiB | 795 MiB | 1058 MiB | 1338 MiB |
TabsOpenForceGC | 600 MiB | 661 MiB | 740 MiB | 936 MiB | 1184 MiB |
TabsClosed | 568 MiB | 663 MiB | 543 MiB | 481 MiB | 435 MiB |
TabsClosedSettled | 451 MiB | 517 MiB | 454 MiB | 426 MiB | 377 MiB |
TabsClosedForceGC | 432 MiB | 480 MiB | 429 MiB | 412 MiB | 374 MiB |
OSX, 64-bit
0 | 1 | 2 | 4 | 8 | |
---|---|---|---|---|---|
Start | 319 MiB | 350 MiB | 342 MiB | 336 MiB | 336 MiB |
StartSettled | 311 MiB | 393 MiB | 383 MiB | 384 MiB | 382 MiB |
TabsOpen | 889 MiB | 1,038 MiB | 1,243 MiB | 1,397 MiB | 1,694 MiB |
TabsOpenSettled | 876 MiB | 977 MiB | 1,105 MiB | 1,252 MiB | 1,632 MiB |
TabsOpenForceGC | 795 MiB | 966 MiB | 1,096 MiB | 1,235 MiB | 1,540 MiB |
TabsClosed | 794 MiB | 996 MiB | 977 MiB | 889 MiB | 883 MiB |
TabsClosedSettled | 738 MiB | 925 MiB | 876 MiB | 823 MiB | 832 MiB |
TabsClosedForceGC | 621 MiB | 800 MiB | 799 MiB | 755 MiB | 747 MiB |
Conclusions
Simply put: the more content processes we use, the more memory we use. On the plus side it’s not a 1:1 factor, with 8 content processes we see roughly a doubling of memory usage on the TabsOpenSettled
measurment. It’s a bit worse on Windows, a bit better on OSX, but it’s not 8 times worse.
Overall we see a 10-20% increase in memory usage for the 1 content process case (which is what we plan on shipping initially). This seems like a fair tradeoff for potential security and performance benefits, but as we try to grow the number of content processes we’ll need to take another look at where that memory is being used.
For the next steps I’d like to take a look at how our memory usage compares to other browsers. Expect a follow up post on that shortly.