Sunday, March 13, 2011

Startup performance of Addon SDK-based extensions

The roadmap for 2011 has improving the add-ons performance as one of this year's goals, so after finishing with my XUL extensions project for the weekend, I did some quick measurements to see what effect add-ons built with the SDK have on the Firefox startup time.

I posted this message to the Add-on SDK discussion group, but reproducing it here anyway.

According to my tests (Mac OS X (10.5) with the latest Minefield and the latest Add-on SDK using getStartupInfo()):
  • an empty SDK-based extension (empty main.js) adds ~20 ms to the 700 ms baseline warm startup time (3%), which is tolerable, but
  • the default extension created with 'cfx init' (adds a simple widget and loads the tabs module) adds more than 200 ms (28%) to the warm startup!
I ran some poor man profiling to check a hypothesis that most of this cost is in the module system (require()). It is very rough, but it showed how most (75%) of the time was spent:
  • 25% (50ms) running es5.js in each of the 38 distinct modules loaded
  • 15% (30ms) is other initialization operations with the sandbox (creating sandboxes, setting properties)
  • 10% (20ms) is spent in fs.getFile(), presumably loading the modules from disk
  • 25% (50ms) spent evaluating the module code itself, not counting the require() costs listed above.
Here are the details of my instrumentation and the results: legend, data:

Counter Hit count Time spent, msAttributed to the
securable-module infrastructure /
to the user-level code?
start loading 3837user
up to createSandbox380s-m
setupSandbox, part 1381s-m
setupSandbox, part 2 - modifyModuleSandbox3854s-m
setupSandbox, part 33815s-m
before evaluate380s-m
after evaluate3852user

The list of all 38 modules loaded by a simple extension using widget and tabs (indenting shows require() dependencies):

  • plain-text-console
  • memory
    • unload
  • main
    • widget
      • xul-app
      • api-utils
      • panel
        • content
          • content/loader
            • events
              • traits
                • traits/core
            • url
            • file
              • byte-streams
              • text-streams
              • xpcom
          • content/symbiont
            • ./worker
              • cuddlefish
                • securable-module
              • timer
            • hidden-frame
              • errors
            • observer-service
      • window-utils
    • tabs
      • windows
        • list
        • windows/tabs
          • tabs/tab
            • utils/function
            • tabs/events
            • utils/thumbnail
            • utils/data
        • windows/dom
        • windows/loader

No comments:

Post a Comment