Performance:Startup
Contents
Goal
Here are the goals of that these brownbags are trying to achieve in order of priority.
- Reduce footprint of embeddable engine and netscape browser
- Reduce pageload time
- Reduce new window open time
- Reduce startup time
What do engineers want from these brownbags ?
- Measurement Tools and Techniques
- Analysis Tools and Techniques
- Patterns to fixing the areas found
This is corresponds closely to the performance/footprint improvement loop : measure -> analyze -> fix -> measure
Target Audience
Brownbag should be targeted at the average engineer. Little assumptions should be made about the knowledge of facilities such as c++, strings, xpcom etc. We should cover facilities and provide patterns that people can use as much as possible even if it is trivial.
Measurement
(start with a New Created Profile)
- Startup: http://www.mozilla.org/performance/measureStartup.html
- Pageload: http://cowtools.mcom.com/page-loader/loader.pl
- IBench Pageload: http://dogspit.mcom.com/ibench/performance_tests/perf_loadspeed.asp
- WindowOpen: mozilla -chrome file:///drive:/mozilla/xpfe/test/winopen.xul
Analysis Tools
Remember the simple things : printfs, #if 0 code and putting timers can go a long way.
- MOZ_TIMELINE http://www.mozilla.org/performance/measureStartup.html
- Quantify [windows] http://www.mozilla.org/performance/profiling-juju.html
- Use optimized / MOZ_PROFILE build
- Increase swap to atleast 500MB
- Use Function level profiling
- Command line arguments: -P 'Default User' file:///c|/tmp/quit.html
- Focus subtree on main1
- jprof [linux] http://www.mozilla.org/performance/jprof.html
- Simon Fraser is working on a graphical analysis tool for mac
- printfs
- #if 0 : a very useful method in easily finding out the cost associated with a #particular piece of code or feature
- mallocsites: Number of allocations http://www.mozilla.org/performance/mallocsites20011031.html
- BloatView - Number of objects created http://lxr.mozilla.org/mozilla/source/xpcom/doc/MemoryTools.html
- set XPCOM_MEM_BLOAT_LOG=1
- strace [linux] - view all system calls made by application
Current Performance Project Plan
http://mozilla.org/performance/Performance_Project.html
Performance Theory
There are two approaches to fixing performance.
- Eliminate the cost - most desirable
- Reduce the cost - better algorithms, data structures, code
Evaluate if eliminating the cost, even conditionally, is possible before rushing to reduce the cost. E.g
E.g. International code was loading charset.properties file on startup. This file contained a mapping of charsets to internal normalized form. It so happens that only a few charsets are encountered by a large % (like 90%) of our users. The fix that Frang Tang and Juraj Betak came with was to make an internal table of those frequently used 5 charsets and load the file only if a charset outside of this list if encountered. Thus the entire cost of loading charset.properties was eliminated rather than thinking about making the file format different so lesser bytes are read in.
Checklist
- Number of files loaded - strace and MOZ_TIMELINE (for files from jar)
- Any Directory enumeration : strace
- Any stat() happening : strace
- Dlls loaded : strace
- Are we eagarly building up any other resources: menus, hashtables
- Number of memory allocations : mallocsites
- datastructure or architectural improvements
- Number of objects created - BloatView
Stats
Here are some interesting stats on our startup:
- Malloc: 22% (122,563 calls)
- new: 15% (102,535 calls)
- free: 3% (82,332 calls)
- delete: 2.3% (70,722 calls)
Tinderbox
Main tinderbox: http://tinderbox.mozilla.org/showbuilds.cgi?tree=SeaMonkey Testerbox: http://tinderbox.mozilla.org/showbuilds.cgi?tree=SeaMonkey-Testerbox
QA measuring startup and page-load
Daily results get posted to netscape.public.mozilla.performance newsgroup