Sunday, October 14, 2007

AMD's CodeAnalyst

Now that I have stabilized the features of ZeroBUGS, I am looking into improving the overall performance and implicitly the user experience.

This weekend I live searched for profiling tools and I found AMD's CodeAnalyst.

On Linux, Code Analyst uses oprofile.

I downloaded the source code for version 2.6.22 of CodeAnalyst and proceeded to build it on a Fedora 5, 64-bit system equipped with an Athlon processor. It is not clear to me whether the 2.6.22 version is a coincidence. Has the kernel version to be an exact match for best results?

I am running 2.6.20 on that box, and the program ran but collected no samples, as per this message
Oprofile engine has encounter error genrating system view

I grepped for the message and found it here:



void opdata_handler091::read_op_module_data()
{
string session = m_session;
vector <string> non_options;

reset_data();

for (size_t i = 0; i < m_op_events.size (); i++) {
non_options.clear ();
non_options.insert (non_options.begin (), m_op_events[i]);
non_options.insert (non_options.begin (), session.data ());

try {
generate_apps_summary(non_options, i);
} catch (op_fatal_error const & e) {
string msg =
"Oprofile engine has encounter error genrating system view:\n\n";
msg += e.what();
m_ca_display->update_display(msg.c_str());
reset_data();
break;
}
}
}


(File /src/ca/libs/libopdata/op091/opdata_handler091.cpp). The reason I am showing the code snippet here (broken English not withstanding) is that I noticed a bad coding idiom: the catch block is doing quite a lot of stuff, and I see several things that could possibly throw.

Nit-picking aside, I rebooted the machine in a different configuration (Ubuntu 6.06, 32-bit, running kernel 2.6.15) and this time I got luckier. I even found a few interesting bottlenecks in ZeroBUGS.

I concluded that the oprofiled / 2.6.20 64-bit kernel combination must be the culprit of my initial lack of success.

It definitely looks like CodeAnalyst is a useful tool, once one gets past the initial small road blocks.

4 comments:

drakula said...

have you tried callgrind and kcachegrind?

Jonner said...

callgrind/kcachegrind are nice but they make your system 'grind' to a halt when you're running them. That makes them quite difficult to work with on a regular basis. That's what makes something like oprofile so useful -- you can profile without affecting your running program much at all. By the way, you might also look into oprofileui as a front-end to oprofile: http://projects.o-hand.com/oprofileui

Anonymous said...

kcachegrind rocks even though it slows down the program as much as valgrind does.

The Free Meme said...

One thing that I could not find in CodeAnalyst is a call graph, but maybe I have not played with it long enough?

I have to try oprofileui (Jonner, thanks for the link).