Firefox/Projects/Startup Time Improvements/joelr notes: Difference between revisions

 
(9 intermediate revisions by the same user not shown)
Line 4: Line 4:


= Current status =
= Current status =
=== September 23, 2009 ===
==== x86-64 ====
I now have x86-64 Firefox up and running on Snow Leopard. Josh Aas did all the work, I just [https://bugzilla.mozilla.org/show_bug.cgi?id=518435 put on the final touches].
==== A shiny new world ====
Damon thinks I should help Josh with the 64-bit port. 64-bit Trace Monkey gives us a [http://www.bailopan.net/blog/?p=595 20% improvement in speed] which beats the 5% DWARF improvement from -fomit-frame-pointer.
I didn't know it was my birthday. I'm leaving the 32-bit world behind. 64 bits here I come!
= Previous statuses =
=== September 22, 2009 ===
I have two bottlenecks on my plate, [https://bugzilla.mozilla.org/show_bug.cgi?id=517045 Bug 517045] and [https://bugzilla.mozilla.org/show_bug.cgi?id=517576 Bug 517576]. Both of them may not be possible to speed up significantly, not without a large research effort. The former requires consultation with the owners and the later requires me to become a layout expert.
Benjamin Smedberg suggested taking care of DWARF symbols in breakpad as that will let us use the -fomit-frame-pointer gcc option. Omitting the frame pointer would result in at least a 5% overall speed up because a register will be freed on x86-32.
DWARF is a [https://bugzilla.mozilla.org/showdependencygraph.cgi?id=464750 tree of dependent bugs], though, and Jim Blandy is working on them. Jim is a Linux guy, though, and also has ECMAScript 5 strict mode to take care of whereas I'm strictly focused on performance optimization.
I'll ask management to see if I can work on DWARF with Jim.
=== September 21, 2009 ===
==== Wins ====
Kudos to Masayuki for fixing [https://bugzilla.mozilla.org/show_bug.cgi?id=517549 Bug 517549]. It's hard to believe but it looks like our Mac Ts [http://graphs.mozilla.org/graph.html#tests=[{%22test%22:%2216%22,%22branch%22:%221%22,%22machine%22:%22169%22},{%22test%22:%2216%22,%22branch%22:%221%22,%22machine%22:%22173%22},{%22test%22:%2216%22,%22branch%22:%221%22,%22machine%22:%22178%22}]&sel=1252833380,1253542320 went down 30%] and it was only 12.3% of my startup. I wonder what happens when [https://bugzilla.mozilla.org/show_bug.cgi?id=517576 Bug 517576] gets fixed, that's 21% of my startup!
One other thing I'm wondering about... What if all the bottlenecks I find will get fixed by someone else? Damon wants me to write code!!!


=== September 16, 2009 ===  
=== September 16, 2009 ===  
==== That mysterious forking ====
Apparently, Firefox forks the first time after a build to rebuild caches, etc. Need to make sure to profile from the 2nd run on. This forking behavior baffled me when I started with DTrace.
==== I'm an idiot ====
I spent a month becoming an expert on DTrace, only to realize that it's not very useful to get a global picture of the bottlenecks because the overhead of tracing everything is so high!
Shark is a much better tool to get a global picture, specially using "Time profile all states" which allocates time spent blocking to the calling function. I overlooked this initially since I did not zero in on the right thread, the one that has ''start'' and ''XRE_main'' or ''exit''. Without this it looks like Firefox is spending most of its time waiting on threads and Mach messages.


==== Timing startup ====
==== Timing startup ====
Line 12: Line 54:


<pre>
<pre>
0.0% 87.7% firefox-bin start
0.0% 92.8% firefox-bin start
0.0% 87.7% firefox-bin main
0.0% 92.8% firefox-bin main
0.0% 86.4% XUL   XRE_main
0.0% 91.6% XUL   XRE_main
0.0% 38.3% XUL   ScopedXPCOMStartup::Initialize()
0.0% 40.8% XUL   nsAppStartup::CreateHiddenWindow()
0.0% 30.9% XUL   nsAppStartup::CreateHiddenWindow()
0.0% 34.7% XUL   ScopedXPCOMStartup::Initialize()
0.0% 11.1% XUL   ScopedXPCOMStartup::~ScopedXPCOMStartup()
0.0% 6.4% XUL   ScopedXPCOMStartup::~ScopedXPCOMStartup()
0.0% 2.5% XUL   nsXPTCStubBase::Stub3()
0.0% 3.4% XUL   ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport*)
0.0% 1.2% XUL   ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport*)
0.0% 2.4% XUL   nsXPTCStubBase::Stub3()
0.0% 1.2% XUL   nsXREDirProvider::DoStartup()
0.0% 0.8% XUL   nsAppStartupNotifier::Observe(nsISupports*, char const*, unsigned short const*)
0.0% 1.2% XUL   nsAppStartupNotifier::Observe(nsISupports*, char const*, unsigned short const*)
0.0% 0.8% HIToolbox   GetCurrentEventKeyModifiers
0.0% 1.2% XUL   XRE_GetBinaryPath
0.0% 0.6% XUL   nsXREDirProvider::DoStartup()
0.0% 7.4% dyld _dyld_start
0.0% 0.5% XUL   RemoveComponentRegistries(nsIFile*, nsIFile*, int)
4.9% 4.9% libSystem.B.dylib _exit
0.0% 0.4% XUL   NS_NewToolkitProfileService(nsIToolkitProfileService**)
0.0% 0.3% XUL   nsToolkitProfile::Lock(nsIProfileUnlocker**, nsIProfileLock**)
0.0% 0.1% XUL   WriteVersion(nsIFile*, nsCString const&, nsCString const&, nsIFile*, nsIFile*)
0.0% 0.1% XUL   nsINIParser_internal::Init(nsILocalFile*)
0.0% 0.1% XUL   LaunchChildMac
0.0% 0.4% XUL   XRE_GetBinaryPath
0.3% 0.4% XUL   XRE_CreateAppData
0.4% 0.4% XUL   NS_LogInit_P
0.0% 6.2% dyld _dyld_start
1.0% 1.0% libSystem.B.dylib _exit
</pre>
</pre>
= Previous statuses =


=== September 14, 2009 ===  
=== September 14, 2009 ===  
Line 797: Line 846:
sudo ./cold.sh static-init.d
sudo ./cold.sh static-init.d
</pre>
</pre>
= Shark tips and tricks =
=== Expanding the call tree ===
Alt-Click does it.
=== CHUD signposts on Snow Leopard ===
There are no CHUD header files on Snow Leopard. If you're only interest is in emitting signposts, the easiest thing for you to do is switch to the syscall method instead.  That'll also mean you won't have to link against the CHUD framework. The full details are in the Shark User Guide, but in brief:
<pre>
int err = syscall(SYS_kdebug_trace, APPSDBG_CODE(DBG_MACH_CHUD, <your code number>) | <type>, arg1, arg2, arg3, arg4);
</pre>
Types are DBG_FUNC_START, DBG_FUNC_END and DBG_FUNC_NONE (for point signposts).
Don't forget to include <sys/kdebug.h> and <sys/syscall.h> for the necessary macros and function.


= DTrace tips and tricks =
= DTrace tips and tricks =
109

edits