Wednesday Apr 19, 2006

How to kill NetBeans performance

There are several things you can do that will have a *huge* impact on NetBeans IDE performance and responsiveness.

The single biggest thing you can do is to make sure your "userdir" is not on a remote file system, (i.e. NFS, samba drive, etc).

What is "userdir" ?

It is a directory where NetBeans IDE stores its meta-data. One of the critical pieces of meta-data stored there is the information used for those productivity enhancing features we all enjoy such as code completion.

By default NetBeans IDE creates "userdir" in your home directory as a ".netbeans" directory with an appended NetBeans IDE version number. Hence, if you are on Linux or Unix, "userdir" is $HOME/.netbeans/. If you are Windows, this directory is usually "C:\Documents And Settings\< your user name>\.netbeans\. The value used for $HOME is the value returned from the Java system property user.home.

If your home directory happens to be a remote file system ... well, we all know performance of a remote file system is not nearly as good as local file systems. And, if your remote file system's responsiveness is like some that I have seen ... it will kill the responsiveness of your NetBeans IDE.

The good news is you can change the location of "userdir". You can specify a "userdir" on the command line when you start NetBeans IDE such as:

$ netbeans --userdir /local/file/system/netbeans/userdir/5.0

Or, you can edit the netbeans.conf file and change the "userdir" location to a local file system. The netbeans.conf file is in < netbeans install dir>/etc.

To make editing of the netbeans.conf easier, Claudio Miranda created nice plugin. Claudio would be glad to share his plug-in. Just drop him a note. Or, perhaps we can convince Claudio to contribute it to the many plug-ins showing up on nbextras.org.

For additional responsiveness, you should also consider using a JDK that is on a local file system too. Code completion in NetBeans IDE uses the JDK's src.zip for displaying Java doc information, (a nice way to ensure you have the latest Java doc for the JDK).

Putting NetBeans projects on local file systems helps too.

Comments:

I like NB, I'd love to use it. Unfortuantelly performance is "horrible" for larger project (1000+ classes). Code completion, navigation, switch from GUI designer to source code, ... is "overkill". I have sources on samba drive (requirement), but even putting sources on local drive didn't help (everything else is on local drive). Yes, there may be something wrong with my project structure, but other IDE (IDEA) works without problems. Does anybody have similar experience?

Posted by MNO on April 20, 2006 at 02:14 AM CDT #

Hmm. I'm using NetBeans on a project with 4000+ classes. I'm not experiencing any sort of performance issues. I've tried IDEA and the 'dark side' IDE. IDEA handled it much better than the 'dark side' IDE, it crashes. There must be more to what you're seeing.

What JDK version are you using and what JVM command line args are you using?

I am using Sun's JDK 1.5.0_06 with these JVM args:

-Xms256m

-Xmx512m

-XX:+UseConcMarkSweepGC

-XX:+CMSPermGenSweepingEnabled

-XX:+CMSClassUnloadingEnabled

-XX:+CMSPermGenPrecleaningEnabled

-XX:PermSize=64m

-XX:MaxPermSize=96m

-Xverify:none

I'm using a rather larger Java heap as a result the large project, (4000+) files. Be careful not to set your Java heap too large, it will force part of your Java heap into virtual memory. Doing a GC on a Java heap which has part of it in virtual memory will kill its performance. I have 1G of RAM on my system. How much do you have on yours ?

Posted by charliebrown on April 20, 2006 at 08:19 AM CDT #

Thanks for you comment Charlie. I'm using jdk1.5.0_05 with following options. HW is Pentium 2.4GHz, 1GB RAM (Acer laptop). I'll try to increse the heaps size. My settings were: netbeans_default_options="-J-Xms64m -J-Xmx256m -J-XX:PermSize=32m -J-XX:MaxPermSize=96m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled" I have changed them according to your comment: netbeans_default_options="-J-Xms256m -J-Xmx512m -J-XX:PermSize=64m -J-XX:MaxPermSize=96m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled" It seems more responsive, but still not as I would like to have it. E.g. code completion for attributes or method within the same file/class takes from 5-22 seconds (to get list of options).

Posted by MNO on April 20, 2006 at 09:18 AM CDT #

5-22 seconds ? Shouldn't be anything like that. It should be much less.

Is this with your source files local or remote ?

On Windows ? Is it XP Pro, XP Home? Or, is it Linux ?

Can you also add, -J-XX:+PrintGCDetails to your command line args in netbeans.conf ?

If you are on Windows, you'll need to run nb.exe from the command line. It's in 'install dir'/bin. If you're on Linux/Unix, you can just run 'install dir'/bin/netbeans.

Then, when you are doing code completion for attributes or methods, tell me what the max GC time. I want to be able to rule out GC as a cause. If you'd like to save the output to a file and e-mail it to me that would be great too. I'm huntch at netbeans.org.

Out of curiousity, I'd be interested in knowing if you could try the latest JDK 6 build, http://java.sun.com/javase/6/download.jsp.

You can still set you project to use JDK 5 as the platform, (right click the Project and select Properties and then under Libraries click Manage Platforms and add JDK 5), you'd just be running the IDE with JDK 6. Use the same JVM command line args for JDK 6 as you have now.

Posted by charliebrown on April 21, 2006 at 09:24 AM CDT #

Another thought that just crossed my mind. :-) If you are running on Windows, try defragging the disk. I suppose it is possible that your; NetBeans IDE, JDK, JDK src.zip and/or projects files are fragmented across the disk.

Posted by charliebrown on April 21, 2006 at 05:06 PM CDT #

Beside the fragmentation issue charliebrown mentioned, since you're running it on a laptop, the harddisk performance might be a bottleneck. Laptop HDs are usually slower (less RPM and less cache) then desktop ones. Have you tried to compare the performance on a desktop?

Posted by mauronr on April 26, 2006 at 12:01 PM CDT #

Hum... that's weird. I use about 1200 classes without any issue. (sometimes double or triple this if I open up my code base in a different branch) I used to have 1G or memory, but I upgraded to 2G (not because of netbeans but because of GCJ that required an incredible amount of memory to compile and link all the java classes). All my files are local. I allow up to 512M of memory (-Xmx512m). I run on fedora core 3.

Posted by Jean-Marie White on April 26, 2006 at 12:24 PM CDT #

Post a Comment:
Comments are closed for this entry.