Remote profiling with NetBeans

NetBeans Profiler- Fundamental Utility…

The NetBeans Profiler is well known as a fundamental utility for analyzing the performance of a Java application, as well as being a very intuitive and simple tool to run (of course, the real job of guessing the meaning of the figures that it produces is another story).

Actually, developing an application with the NetBeans IDE and profiling in just a couple of clicks is nice; but sometimes it is not the best option.

CPU Cores and Large Monitor

In fact, unless you have a good number of CPU cores, the problem is that your profiled application, that is already slowing down because of the code instrumentation, has also to share the CPU with NetBeans and the profiler itself.

Furthermore, unless you have a very large monitor (or a dual monitor), profiling a desktop application implies bringing the application and the profiler windows forward and backward – this triggers a lot of AWT repaint events that interfere with your monitoring job.

What do I think?

In my opinion, this can be only solved by using two computers: the profiler, in fact, is able to run remotely (as the debugger). So, yesterday night I used my new Asus EEE PC for a new task (I originally bought it to have a few computing power with me when I hike… but it’s turning to be a great mobile lab companion).

Configuring MacBook and Asus

So, I first connected my MacBook Pro and my Asus EEE PC, both running Linux Ubuntu; then I pointed Firefox to and downloaded the Profiler Remote Pack for my platform (Linux 32bit).

I installed it by unpacking the .zip in /usr/share/profiler-server. Then I opened the bin/ script and un-commented the definition of JAVA_HOME making it to point to the Java installation (/usr/lib/jvm/java-6-sun).

I made sure that there were no other processes sucking the CPU and ran it: it performed a one-time-only calibration to measure the speed of my computer (a similar procedure is performed by the profiler embedded in NetBeans).

By the way,

I didn’t need to run it as root even though I performed a root installation of the remote profiler pack.

Then I added this target to the build.xml of blueMarine

    <property name="profiler-server"
    <target name="profile-remote" description="Profile a project
        <antcall target="run">
            <param name="run.args"

and then I launched it with ant profile-remote. The application started and blocked, waiting for the Profiler to be launched-

Output Window


[exec] Profiler Agent: Initializing...
[exec] Profiler Agent: Options: >/usr/share/profiler-server/lib,5140<
[exec] Profiler Agent: Initialized succesfully

Launching NetBeans on Asus EEE…

At this point I went to my EEE and launched NetBeans (opening the blueMarine project, I have the sources on both computers). After selecting the menu Profile/Attach Profiler…, I entered the following information in the sequence of dialogs that appeared-

Analyze Performance: Entire application

Target Type: Application
Attach method: Remote
Attach invocation: Direct (other options were grayed out)

Hostname: (the IP address of the MacBook Pro)
Host OS: Linux

Then I pressed Finish. The profiler was launched, it unblocked blueMarine and started instrumenting the code-

[exec] Profiler Agent: Established remote connection with the tool
[exec] Profiler Agent: Redefining 100 classes at idx 0, out of total 523
[exec] Profiler Agent: Redefining 100 classes at idx 100, out of total 523
[exec] Profiler Agent: Redefining 100 classes at idx 200, out of total 523
[exec] Profiler Agent: Redefining 100 classes at idx 300, out of total 523
[exec] Profiler Agent: Redefining 100 classes at idx 400, out of total 523
[exec] Profiler Agent: Redefining 23 classes at idx 500, out of total 523
[exec] ----------------------------------------------------

In the short video below you can see me while I’m stressing the thumbnail renderer, while the profiler is telling me if there are problems with the AWT Thread.

Video coming soon!

I discovered that sometimes the AWT Thread is blocked in a monitor contention, which is not good (and I expected that since sometimes blueMarine gets sluggish). It has been really important to be able to see the profiler telemetry in real time while the blueMarine user interface was completely unobstructed.

Thank you

This is it, Fabrizio Giudici did blog this entry, reason being he’s my fourth special guest blogger, who was invited to blog the 95th entry over here.

Though, he’s famous for his RCP application blueMarine and his weblog, he’s an active blogger there, and share his invaluable experience, he got by working on blueMarine and being a Java Architect for past several years.

Fabrizio, thank you so much 🙂 It was indeed a pleasure to have you blog over here.

Fabrizio Giudici is a Senior Java Architect with a long J2EE experience; in the latest two years he expanded his interests to Jini and NetBeans. Fabrizio has been running, his own consultancy company, since 2001 and has been a technical speaker at JavaOne, JavaPolis, Jazoon, Jini Community Meetings and some Italian Java conferences.

He started working with Java since the old 1.0 times and after 1.3 he has been committed in demonstrating that Java performance is not an issue, really. After bringing Java to the world of Formula One telemetry, he believes he is on the right path. He has a strong interest in photography and is writing an opensource application for photo management called blueMarine. Fabrizio is a member of the JUG Milano and of the NetBeans Dream Team.

4 thoughts on “Remote profiling with NetBeans

  1. I would love some more stories on the profiler and how to find common issues with it. Installing the profiler is one thing – getting valuable information out of it is another.

    Title suggestion: “Using the Netbeans profiler to tune a web application and database backend”.

  2. Pingback: RIA’s using PHP Support in NetBeans « N, Varun

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s