The Performance Drain of Firefox Extensions
I've encountered an annoying performance bottleneck in our current web-app. The app isn't particularly optimized; so this isn't surprising. Normal overview pages take more than a second to load (on an unloaded server!) I turned to the simplistic instrumentation we've fitted to the web app, looking to see which part of the request processing was taking so long. Oddly enough, according to the framework, the pages were taking only slightly more than 100ms each to generate. However, Firefox's CPU time was rising by more than a second each pageview. The act of Viewing the website had become a CPU-limited task.
To get an idea of what's causing this I performed a really simple test:
- Start the browser (set to show a blank page on startup)
- Paste the login-URL into the location bar
- Log in
- Perform 10 pageviews
The wall-clock time it takes to perform this test varies quite a lot depending on the test-taker, but the CPU-time varies far less, so that's what I measured: the CPU time necessary to start the browser, and, with minimal user interaction, show 12 web pages.
My normal Firefox installation needs 20.1 seconds to do that. Internet Explorer 7 needs 10.0 seconds, and feels far snappier. Of course it's not a fair comparison since my IE installation is mostly bare, whereas Firefox is loaded with Extensions and a huge number of bookmarks. The inevitable question arises: how much time does a bare Firefox install need? I disabled all extensions, and moved my bookmarks.html file to a new location. This bare install of Firefox needs 8.7 CPU seconds.
Installing 10 extensions and making a lot of bookmarks slowed Firefox down 131%.
At this point I tried a number of different configurations to find out which Extension is the culprit. Unfortunately, no single extension is responsible; though some are clearly more guilty than others:
- Bare: 8.7 seconds
- Normal (+ 300 KB of bookmarks): 9.0 seconds
- Normal + Firebug + Webdev bar + DOM Inspector + Fasterfox + Dutch spelling dictionary + Talkback: 10.5 seconds
- As above + Google browser sync: 12.3 seconds
- As above + Adblock + Adblock updater: 14.4 seconds
- As above + Google toolbar (Full): 20.1 seconds
- Normal + Adblock + Adblock updater: 10.3 seconds
- Normal + Google toolbar: 14.1 seconds
Clearly the Google products are very slow. Adding the Google toolbar to the rest accounts single-handedly for 5.7 seconds of slowdown; or almost 1/2 a second per page! A valid question would now be: is actual browsing slower, or just the startup? Well, startup times (including one simple pageview to avoid caching cheats) are as follows:
- Bare: 1.9 seconds
- Normal: 2.1 seconds
- Normal + Firebug + Webdev bar + DOM Inspector + Fasterfox + Dutch spelling dictionary + Talkback: 3.5 seconds
- As above + Google browser sync: 4.9 seconds
- As above + Adblock + Adblock updater: 6.3 seconds
- As above + Google toolbar (Full): 7.9 seconds
- Normal + Adblock + Adblock updater: 3.3 seconds
- Normal + Google toolbar: 4.3 seconds
It seems Google browser sync's extra CPU time is mostly needed during startup (1.4 seconds vs full test 1.8). Bookmarks make a barely noticeable difference in startup time and no difference thereafter (0.2 vs. 0.3). The Google toolbar is really slow both during startup and thereafter (1.6 vs. 5.7). Adblock's delay is largely during startup; but these were internal webapp pages and didn't contain any ads for adblock to block (1.4 vs. 2.1). All the others essentially exclusively increased the start up time (1.4 vs. 1.5).
Moral of the story?
Extensions always slow down your startup, and stay away from the Google toolbar.
