[] Profiling Venkman / JSD startup

So the last few days I’ve been trying to get a profile of Venkman/JSD startup. First I’ll talk about the hurdles I met along the way for a bit. I decided that the results and conclusions I took from them are probably better off on a wiki page. Please feel free to let me know what you think about them.

Problems and stuff

First of all, I wanted to do a profile on my Windows box, because it’s faster than anything else I have access to, and I really wanted this to not be a task taking me more than a few hours, maybe a day. Wrong plan. There are no open-source/free profile tools that I could find (documentation/explanations of). On Linux, there was more choice, and several people told me that was probably easier for me. Okay, I thought, then we’ll have to do it on Linux, I guess. Not very nice, but oh well.

Surprise surprise, there is documentation! I’ll probably move that to DevMo/wiki.m.o if desired, and if/when I have spare time. So, off I went, trying to build with the following .mozconfig:

# Options for client.mk.
mk_add_options MOZ_CO_PROJECT=suite,browser,mail,xulrunner
mk_add_options MOZ_OBJDIR=/home/gijs/moz_dev/firefox-opt-jprof/
mk_add_options MOZ_MAKE_FLAGS="-s -j4"

# Options for 'configure' (same as command-line options).
ac_add_options --enable-application=browser
ac_add_options --enable-debugger-info-modules
ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --enable-jprof

The first hurdle was that jprof required bfd.h. My build failed, I apt-got binutils-dev, and then that part of the build was happy again - except that it then started to complain that _r_debug was not defined. After some lxr-ing, I wondered what was up, because this seemed to be something that should get from some external thing (meaning, a header or library or other ‘thing’ not provided by mozilla itself), yet neither make nor ld was complaining about missing headers. When complaining in #developers, biesi fortunately heard me and told me to put EXTRA_DSO_LDOPTS += /lib/ld-linux.so.2 in the Makefile.in for the directory that was failing (mozilla/tools/jprof/stub). After that, the build worked fine.

That said, it was very slow. In the meantime, I’d used some spare unpartitioned space on my main Windows machine to install Ubuntu Dapper. The laptop was running Ubuntu Breezy, and after the build was done, I updated that machine to Dapper as well. After that I tried to profile my build which seemed, not counting some hurdles with which dbaron helped me, to work fine. However, when I ran jprof on the resulting jprof-log file, it complained it couldn’t find a library file. Oops. I now (after the OS update) had a different version of that library, rendering the build mostly useless (at least, that’s my diagnostic of what happened - I didn’t look into it too much, maybe I’m wrong and something else was broken, I don’t know). Regardless, I rm -fr‘d my OBJDIR, and started the build anew.

By now I had overcome some entirely unrelated problems with Ubuntu Dapper on my main machine, and after some time, noticing how slow the build on my laptop was, I started a cvs checkout on my main machine. After installing cvs, that is (why is that not in a default Dapper install - and why did Dapper not let me pick the software I wanted when I was installing in Expert mode?). Then I did a checkout (after installing make, anyway), and meanwhile used apt-get to install gcc, g++, libidl and all the other prerequisites to do anything useful with a cvs checkout.

When my checkout was done, I ran a build, then realized I’d forgotten to separately checkout jprof and edit the Makefile to make sure I wouldn’t get the same problem. I did those things while the build was already running, and surprisingly that worked. My main machine was done before the laptop (I partially blame my addition of --disable-tests to the .mozconfig on my main machine for that extremely large difference).
I then ran a profile on my main machine (in a nutshell, I set the environment variable JPROF_FLAGS to “JP_DEFER JP_PERIOD=0.0011″, ran Firefox, sent it a PROF signal, started Venkman, sent Firefox a USR1 signal as soon as Venkman was done loading, and then exited Firefox (and Venkman)). After checking the results, I was suspicious for the lack of jsd stuff in there. I then realized this profile still had Firebug installed, which I suspected would get its debugger interface sorted out as soon as the first Firefox window got loaded. So I deinstalled Firebug and tried again. The next day (today) I did the same thing on my laptop. The results are on wiki.mozilla.org.

Leave a Reply