When reporting a performance problem with Firefox, or when experiencing instances of Firefox stuttering or otherwise being unresponsive to input, obtaining a snapshot of what's going on during that period is extremely helpful for developers. This page will walk you through using the freely available AMD CodeAnalyst tool to create such a snapshot.
Download and Install AMD CodeAnalyst
Download AMD CodeAnalyst for Windows from AMD's Developer site. (You may need to create an account.) Make sure you download the latest version, which at the time of this writing is 2.94. The download site is a little unclear, often offering links to multiple versions.
The installer will ask that you restart, but I've found that in most cases that's not necessary. You can begin profiling without restarting, though if you experience problems, you may want to try restarting just in case.
Start a Profiling Run
Start CodeAnalyst by double-clicking its icon. You'll see the following:
Select Express Profile.
You'll be presented with the following:
Leave everything at the defaults, and click OK.
As soon as you click OK, profiling starts, and will run for about 30 seconds.
Set up the Mozilla Symbol Server
After the first profiling run finishes, you'll see the following:
Before we can extract useful data, we'll need to set up access to the Mozilla Symbol Server.
From the Tools menu, select CodeAnalyst Options. In the options dialog, select the Directories tab.
- Check Use Symbol Servers
- Enter a directory for the Download directory; something like C:\SymCache works. This is a location where symbol data will be downloaded and cached to.
- The Microsoft symbol location should already be in the list of symbol sources, so all you need to do is add the Mozilla server. Click New.
- Enter http://symbols.mozilla.org/firefox
Your options dialog should look like this:
Click OK. Symbols are available for all released versions of Firefox, as well as for the last 30 days' worth of nightly builds.
Examining Profiling Data
You're now ready to examine the data that you captured! The results window will have a few tabs in it; select Processes. You'll see a list of all the processes that were running while the sample was captured, along with the percentage of samples that happened within them:
In this case, Firefox was using 42% of the system time. That's a good percentage; the higher you see firefox in the list, the easier it is to track down the problem, because it means that more data was captured. Now we want to drill in to firefox.exe, so double click firefox.exe. You'll see a module view of the Firefox process:
In the above example, most of the time is spent inside xul.dll, so let's focus on that. Double click xul.dll.
CodeAnalyst will spend some time downloading symbols if it hasn't done so before, and eventually you'll see the following view:
If, in the previous step, the time was split between multiple modules, you should repeat the above for each module of interest (for example, for xul.dll and js3250.dll.
Capturing Another Sample
If the problem you are trying to analyze is intermittent, it's helpful to leave the CodeAnalyst window open. When it appears, just hit the green Start button in the window to start profiling, and when the slowness/lockup stops, hit the stop button. That will give you a new session with just that information. It can be difficult to do this for short problems, and might take a few tries to get a useful profiling sample.
What To Do With The Data
At this point, you have information that's very useful when filing a bug report regarding performance in bugzilla.mozilla.org. The easiest way to get data into a bug report is to select the top ten symbols or so, right click, and select Copy selection to buffer. You can then paste the result directly into a bug report. Or, select Export data to file and attach the file to the bug.
Filing a peformance-related bug with the profile information attached lets developers immediately have an area that they can look at, especially for intermittent or hard-to-reproduce problems.