Profiling with AMD CodeAnalyst

  • Revision slug: Profiling_with_AMD_CodeAnalyst
  • Revision title: Profiling with AMD CodeAnalyst
  • Revision id: 111489
  • Created:
  • Creator: VladVukicevic
  • Is current revision? No
  • Comment 365 words added, 1 words removed

Revision Content

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.

This page applies to Windows only, because of the dependency on obtaining symbols from the Mozilla Symbol Server.  On MacOS X, a special Shark-enabled build can be used which has symbol information already built in.  On Linux, a custom build would be required.
If you are on a 64-bit version of Windows, AMD CodeAnalyst has some known problems that may cause blue screen crashes when your computer idles, especially on non-AMD CPUs.  You may want to avoid using CodeAnalyst until the problem is resolved.

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.

Start a Profiling Run

Start CodeAnalyst by double-clicking its icon.  You'll see the following:

codeanalyst1.PNG

Select Express Profile.

You'll be presented with the following:

codeanalyst2.PNG

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:

codeanalyst4.PNG

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:

codeanalyst5.PNG

Click OK.

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:

codeanalyst6.PNG

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:

codeanalyst7.PNG

There are two main modules that are relevant for Firefox -- xul.dll and js3250.dll.  The vast majority of what Firefox does is part of xul.dll; everything except JavaScript execution, which is part of js3250.dll.

Revision Source

<p>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.</p>
<div class="note"><strong>This page applies to Windows only</strong>, because of the dependency on obtaining symbols from the <a class="internal" href="/en/Using_the_Mozilla_symbol_server" title="en/Using the Mozilla symbol server">Mozilla Symbol Server</a>.  On MacOS X, a special Shark-enabled build can be used which has symbol information already built in.  On Linux, a custom build would be required.</div>
<div class="warning"><strong>If you are on a 64-bit version of Windows</strong>, AMD CodeAnalyst has some known problems that may cause blue screen crashes when your computer idles, especially on non-AMD CPUs.  You may want to avoid using CodeAnalyst until the problem is resolved.</div>
<h3>Download and Install AMD CodeAnalyst</h3>
<p>Download <a class="external" href="http://developer.amd.com/cpu/CodeAnalyst/codeanalystwindows/Pages/default.aspx" title="http://developer.amd.com/cpu/CodeAnalyst/codeanalystwindows/Pages/default.aspx">AMD CodeAnalyst for Windows </a> from AMD's Developer site.  (You may need to create an account.)  <strong>Make sure you download the latest version, which at the time of this writing is 2.94.</strong>  The download site is a little unclear, often offering links to multiple versions.</p>
<h3>Start a Profiling Run</h3>
<p>Start CodeAnalyst by double-clicking its icon.  You'll see the following:</p>
<p><img alt="codeanalyst1.PNG" class="internal default" src="/@api/deki/files/3781/=codeanalyst1.PNG" style="width: 454px; height: 353px;"></p>
<p>Select <strong>Express Profile</strong>.</p>
<p>You'll be presented with the following:</p>
<p><img alt="codeanalyst2.PNG" class="internal default" src="/@api/deki/files/3782/=codeanalyst2.PNG" style="width: 529px; height: 337px;"></p>
<p>Leave everything at the defaults, and click OK.</p>
<p>As soon as you click OK, profiling starts, and will run for about 30 seconds.</p>
<h3>Set up the Mozilla Symbol Server</h3>
<p>After the first profiling run finishes, you'll see the following:</p>
<p><img alt="codeanalyst4.PNG" class="internal default" src="/@api/deki/files/3783/=codeanalyst4.PNG" style="width: 918px; height: 542px;"></p>
<p>Before we can extract useful data, we'll need to set up access to the Mozilla Symbol Server.</p>
<p>From the <strong>Tools</strong> menu, select <strong>CodeAnalyst Options</strong>.  In the options dialog, select the <strong>Directories</strong> tab.</p>
<ul> <li>Check <strong>Use Symbol Servers</strong></li> <li>Enter a directory for the <strong>Download directory</strong>; something like <strong>C:\SymCache</strong> works.  This is a location where symbol data will be downloaded and cached to.</li> <li>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 <strong>New</strong>.</li> <li>Enter <strong><a class=" external" href="http://symbols.mozilla.org/firefox" rel="freelink">http://symbols.mozilla.org/firefox</a></strong></li>
</ul>
<p>Your options dialog should look like this:</p>
<p><img alt="codeanalyst5.PNG" class="internal default" src="/@api/deki/files/3784/=codeanalyst5.PNG" style="width: 445px; height: 621px;"></p>
<p>Click OK.</p>
<h3>Examining Profiling Data</h3>
<p>You're now ready to examine the data that you captured!  The results window will have a few tabs in it; select <strong>Processes</strong>.  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:</p>
<p><img alt="codeanalyst6.PNG" class="internal default" src="/@api/deki/files/3785/=codeanalyst6.PNG" style="width: 918px; height: 569px;"></p>
<p>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 <strong>double click firefox.exe</strong>.  You'll see a module view of the Firefox process:</p>
<p><img alt="codeanalyst7.PNG" class="internal default" src="/@api/deki/files/3786/=codeanalyst7.PNG" style="width: 918px; height: 569px;"></p>
<p>There are two main modules that are relevant for Firefox -- xul.dll and js3250.dll.  The vast majority of what Firefox does is part of xul.dll; everything except JavaScript execution, which is part of js3250.dll.</p>
Revert to this revision