Wednesday, April 25, 2012

Optimising the JVM/JRE for Eclipse Indigo

I've found these resources for optimizing the Java JRE/JVM for Eclipse.




I've also got a fair bit of experience tuning the JVM myself. This post will detail my current settings and the work-in-progress changes.

I'm looking for:

  1. Performance
  2. Stability
  3. Getting rid of the Java abnormal workbench condition thing that munges and reverses cut-and-paste text!
  4. Ability to do other stuff at the same time!

Specs of development machine:

  • Dell Studio XPS 1470
  • CPU: Intel i5 M540 @ 2.53Ghz
  • 4GB memory
  • 64-bit
  • Windows 7 Ultimate
  • Fairly new, clean OS install

My current Eclipse configuration is:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.javascript.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m

Frankly, this just doesn't cut it...

Download a new JRE

Java 7 is not supported for Eclipse Indigo as far as I have been able to tell.
So, we'll download the latest JRE version 6. This is JRE 6u31 as of 25th April 2012.
I downloaded from here:

For the purposes of this blog post, I have created a folder called 'other_jres' inside the main Eclipse folder. This is because I want to keep the portability of Eclipse and it's convenient!
Then, I installed the JRE in eclipse\other_jres\jre-6u31.

Change Eclipse start-up options


For validations: on Eclipse menu Windows -> Preferences -> Validation, click “Disable All”, and then select the validator which you need. I selected “Classpath Dependency Validator” only. (MDH: for me, this was just Disable All and don't re-enable anything)
For startup action: on eclipse menu Windows -> Preferences, type “startup”, select “Startup and Shutdown”, untick the options you don’t need. (MDH: I've left CFEclipseCall and the Equinox Provisioning ones checked) 
(paraphrased) Exclude the Eclipse app folder and your workspace folder from your antivirus.

Change the configured JVM

I want to make damn sure that I don't run the pre-existing one, so rename the eclipse\jre folder to _old_jre. When you try and start Eclipse now, it should fail.

Now, open up the eclipse.ini file. Add the following line to the top:
-vm
C:\......\eclipse\other_jres\jre-6u31\bin

Run Eclipse just to make sure it works. If it doesn't, you need to check the path and also make sure you've installed the JRE, not any other type of Java. There are a lot of them!

Here's where the experiments start.

Experiment 1

I changed the -vmargs section to:
-vmargs
-server
-Dosgi.requiredJavaVersion=1.5
-Xmn128m
-Xms1024m
-Xmx1024m
-Xss2m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:+UseParallelGC

The -server option seems to improve things a lot, according to other posts. I have gone for a higher memory usage because I edit quite large code files.
The other options I am NOT explaining as I often get it wrong! Look for JVM options on Google!

Result 1

Still had the same problem with pasting causing the current page editor to munge the pasted content and make the file non-editable until re-opening.

Experiment 2

-vmargs

-server
-Dosgi.requiredJavaVersion=1.5
-Xmn128m
-Xms1024m
-Xmx1024m
-Xss2m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:+ScavengeBeforeFullGC
-XX:-UseParallelOldGC
-XX:+UseCompressedOops
-XX:MaxGCPauseMillis=10


Let's see what that gives us!

Notes

Remember - you can use # marks to comment things out so don't be afraid to experiment.
Other options I will be trying:
# Other options to try
#-XX:+UnlockExperimentalVMOptions
#-XX:+UseG1GC
#-XX:+UseFastAccessorMethods

#-XX:+ScavengeBeforeFullGC
#-XX:-UseParallelOldGC

#-XX:+UseCompressedOops
#-XX:MaxGCPauseMillis=10

The search continues...


No comments: