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

no edit summary
No edit summary
Line 4: Line 4:


= Current status =
= Current status =
=== August 30, 2009 ===
Using my "Lego blocks" [http://github.com/wagerlabs/firefox-startup/tree/master DTrace toolchain] I thought I would check the "hot paths" through Firefox code during the first 20 seconds of startup.
<pre>
./d firefox-bin hotpath.d stop-20s.d
dtrace -Zqw -x dynvarsize=64m -x evaltime=preinit -p 1478  -s hotpath.d -s stop-20s.d -s sigcont.d
kill -CONT 1478
  XUL`gfxContextAutoSaveRestore::Reset(gfxContext*)              2766
  firefox-bin`0x0                                                2234
  XUL`operator new(unsigned long, void*)                          348
  XUL`gfxImageSurface::Height() const                            335
  XUL`gfxPattern::Release()                                        60
  XUL`DumpJSValue                                                  44
  XUL`gfxContextAutoSaveRestore::gfxContextAutoSaveRestore(gfxContext*)              29
  XUL`gfxUserFontSet::Release()                                    17
  XUL`gfxImageSurface::Data() const                                16
  XUL`gfxContextPathAutoSaveRestore::~gfxContextPathAutoSaveRestore()                8
</pre>
I'm sampling at 997Hz so that's roughly 2.7s for the top result. A small script is all it took to see where ''gfxContextAutoSaveRestore::Reset'' is being called from.
<pre>
BEGIN
{
  i = 0;
}
pid$target::gfxContextAutoSaveRestore??Reset(gfxContext*):return
/ i < 10 /
{
  printf("arg0: 0x%x, arg1: 0x%x\n", arg0, arg1);
  ustack();
  i++;
}
pid$target::gfxContextAutoSaveRestore??Reset(gfxContext*):return
/ i >= 10 /
{
  exit(0);
}
</pre>
The [http://gist.github.com/177980 stack traces] (first one of ten below) include ''gfxImageSurface::Height'' and ''DumpJSValue''.
<pre>
./d firefox-bin autosave.d
dtrace -Zqw -x dynvarsize=64m -x evaltime=preinit -p 1527  -s autosave.d -s sigcont.d
kill -CONT 1527
arg0: 0x90, arg1: 0x1a71da8
              XUL`gfxContextAutoSaveRestore::Reset(gfxContext*)+0x90
              XUL`gfxImageSurface::Height() const+0x2d976
              XUL`gfxImageSurface::Height() const+0x135b6
              XUL`gfxImageSurface::Height() const+0x107b7
              XUL`non-virtual thunk to nsPrintSession::QueryInterface(nsID const&, void**)+0x53d16
              XUL`non-virtual thunk to nsPrintSession::QueryInterface(nsID const&, void**)+0x53f1b
              XUL`NS_GetComponentRegistrar_P+0x21cd
              XUL`NS_GetComponentRegistrar_P+0x2324
              XUL`NS_GetComponentRegistrar_P+0x4964
              XUL`non-virtual thunk to nsPrintSession::QueryInterface(nsID const&, void**)+0x4b3fd
              XUL`non-virtual thunk to nsPrintSession::QueryInterface(nsID const&, void**)+0x4b850
              XUL`non-virtual thunk to nsPrintSession::QueryInterface(nsID const&, void**)+0x4a9e1
              XUL`DumpJSValue+0x1dfbab
              XUL`DumpJSValue+0x1e0103
              XUL`gfxCornerSizes::gfxCornerSizes(gfxSize const&, gfxSize const&, gfxSize const&, gfxSize const&)+0xc9e8e
              XUL`gfxCornerSizes::gfxCornerSizes(gfxSize const&, gfxSize const&, gfxSize const&, gfxSize const&)+0xb64b4
              XUL`gfxCornerSizes::gfxCornerSizes(gfxSize const&, gfxSize const&, gfxSize const&, gfxSize const&)+0xbb918
              XUL`gfxCornerSizes::gfxCornerSizes(gfxSize const&, gfxSize const&, gfxSize const&, gfxSize const&)+0x151bdf
              XUL`gfxCornerSizes::gfxCornerSizes(gfxSize const&, gfxSize const&, gfxSize const&, gfxSize const&)+0x14e234
              XUL`gfxCornerSizes::gfxCornerSizes(gfxSize const&, gfxSize const&, gfxSize const&, gfxSize const&)+0x14ed99
</pre>
''gfxImageSurface::Height'' is low-hanging fruit, defined as
<pre>
PRInt32 Height() const { return mSize.height; }
</pre>
I would suggest making it inline and checking results again.
''DumpJSValue'' is trickier because it appears to be a [http://mxr.mozilla.org/mozilla-central/source/js/src/xpconnect/src/nsXPConnect.cpp#2714 JavaScript API function]. Still, it's called during the static initialization portion of dynamic linking and all that printing is not helping in a release version of Firefox.
<pre>
./d firefox-bin dump-js-value.d
dtrace -Zqw -x dynvarsize=64m -x evaltime=preinit -p 1579  -s dump-js-value.d -s sigcont.d
kill -CONT 1579
              XUL`DumpJSValue+0x3917
              XUL`DumpJSValue+0x3b92
              XUL`0x111c146
              XUL`0x111c161
              dyld`ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&)+0xeb
              dyld`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int)+0xf6
              dyld`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int)+0x9a
              dyld`ImageLoader::runInitializers(ImageLoader::LinkContext const&)+0x3d
              dyld`dyld::initializeMainExecutable()+0x86
              dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**)+0x105d
              dyld`dyldbootstrap::start(macho_header const*, int, char const**, long)+0x30b
              dyld`_dyld_start+0x27
              firefox-bin`0x1000
</pre>
I suppose the invocation should only be compiled in in a debug version of Firefox but I'm still searching for that invocation!
= Previous statuses =


=== August 28, 2009 ===
=== August 28, 2009 ===
Line 40: Line 148:


The above assumes that I launch Minefield.app after ''d'', from the dock, Finder, command line, etc.
The above assumes that I launch Minefield.app after ''d'', from the dock, Finder, command line, etc.
= Previous statuses =


=== August 27, 2009 ===
=== August 27, 2009 ===
109

edits