Thursday 12 March 2015

Eclipse Having a Slow Day? Speed it up in a Few Clicks!

Eclipse is the market leading IDE of choice for Java developers. It’s a rich featured IDE which makes developing code in Java super simple. However, we’ve all at some point said or thought to ourselves, “Wow, my Eclipse is slow today, what’s it doing?”. To be honest, it might be working on a bunch of tasks that event the Eclipse foundation aren’t sure about, but some of which we can explain to you, and eliminate for you so that your Eclipse can run faster, just like when you first unwrapped it.

Oh by the way, we’ve created an Eclipse plugin, available for free, which configures Eclipse automatically for you. It does everything we mention in this blog for you, and even tells you how much faster you’ve become! It's called Optimizer for Eclipse and you can check it out here. Oh and how about these awesome graphic that our design team did for us - Jetpack for Eclipse, Whoooosh!

How can I fix it?

Here are the topics which are the typical culprits when working out what might be slow on your Eclipse environment.
  • Insufficient memory allocation 
  • Class verification overhead 
  • Excessive indexes and history 
  • Obsolete or slow JDK 
  • Eclipse being out of date 
  • Lengthy build and redeploy times 
Each of these areas can afflict different amounts of pain to different developers, based on how long you’ve used the installation for, your type and number of projects. Let’s go through each one individually and show you how you can fix them. Remember, your milage may vary.

Insufficient memory allocation

This might seem obvious, but Java applications are rarely tuned with reasonable Java memory settings from the outset and you’d be well advised to change yours to reduce constant heap expansion which really slows general startup and running down. Your settings will of course depend on your detailed environment, but here are some suggested settings which will give you a much more performant environment from the outset:


There’s also a +UseParallelGC flag used to dictate which garbage collector strategy to use. This strategy maximises the garbage collection pause, meaning the time between when garbage collection is invoked, while keeping the memory footprint low

There’s no need to enter these in manually yourself, let the free Optimizer for Eclipse plugin do it for you!

Class verification overhead

Class verification is where the JVM sifts through your class files when they’re loaded and verifies that class data is not corrupt or invalid. This is only really important if you’re manipulating byte code anyway. Plugins also go through the same checks and this can be a big overhead. We’re talking 10-20% startup improvement. So how can you fix it? Well, you need to use the -Xverify:none option on your JVM, which disables class verification. Or just click the relevant button on the Optimizer for Eclipse plugin and let us do it for you!

Excessive indexes and history

I remember being at school, sitting in my history class thinking... Wow, this is incredibly boring. Well, Eclipse history is just as boring, and it has the same effect too. It manages to make time feel longer than it actually is. Eclipse stores a bunch of info in indexes and history which build up over time. It stores them in two directories as follows:

{workspace path}/.metadata/.plugins/org.eclipse.jdt.core

{workspace path}/.metadata/.plugins/org.eclipse.core.resources/.history

Eclipse spends a lot of time going through these files and if you have excessive build up in these directories, you could be experiencing a lot of churn around start up and general running. It’s important to clean up your history and indexes periodically. Optimizer for Eclipse will clear this for you and remind you when it thinks you need to give it a spring clean again.

Obsolete or slow JDK

The latest version of Java available today is version 8. You know that right? Thought so, just checking. Big performance improvements are made in each version of Java when new versions are released and it just makes sense to upgrade, if possible. Of the available (non-beta) Java releases out today, the Oracle JDK looks to be the most performant and so is recommended for use with Eclipse.

Eclipse being out of date

There are a number of reasons why being on a recent driver of Eclipse is important. Firstly, and least importantly, it’s super shiny and you’ll make all your friends and colleagues feel jealous and old fashioned when they realise their Eclipse version isn’t named after a popular chocolate bar. Secondly and more importantly, the Eclipse foundation do put a lot of work in to make Eclipse more performant, so you may as well make use of these enhancements in the newer drivers. Plugins tend to be written and updated for the more recent versions, so you’ll soon potentially find yourself in a poorly performing environment, and remember, not all plugin updates will even support a lot of the older versions of Eclipse. Obviously, if you’re running and stuck on a legacy plugin which you depend on, and it doesn’t support a newer version of Eclipse, this may not be an option for you, but this is quite rare.

Lengthy build and redeploy times

We of course know that one of the major pain points when developing applications in Java is having to build, compile, package, restart/redeploy, generate state, ZZzzzzz. And all this before you can even think about testing or seeing your code changes. Well, there’s no need to worry or grow old beyond your years as there is a solution. It wears a cape, and goes by the name of JRebel. A tool which has a deep integration with Java Classloaders, application servers and Java frameworks that allow you to instantly reload your code changes! You can learn more about the tool on the JRebel product pages, and either install directly through the marketplace, or via the Optimizer for Eclipse plugin. (*Note* JRebel does of course work on all the other major IDEs too!)

If you want to try out the Optimizer for Eclipse tool, which does much of what we’ve talked about automatically, oh and for free, you can download the Eclipse plugin and give it a go.

Here's a video so you can see it in action.

Originally posted on the RebelLabs blog.

No comments:

Post a Comment