How do I optimize GWT compiler for faster compilation?

I use eclipse IDE for my GWT application development. GWT is a great way to develop web applications but to do quick server side code test takes long time due to GWT compilation process. Thankfully I found a way to speed up GWT compilation by making small configuration changes.

If you are targeting specific browser then you can always define user agent in UserAgent.gwt.xml file as follows:

<set-property name="user.agent" value="ie6"/>

You can also speed up by isolating locales as follows:

<extend-property name='locale' values='en'/>

In the newer versions of GWT, you can add <collapse-all-properties /> to your yourapp.gwt.xml for development purposes. That will tell the GWT compiler to create a single permutation which covers all locales and browsers. That means you can test in all browsers and languages but are still only compiling a single permutation.

Compiling a single permutation that handles all browsers and languages still takes a little bit more time than a single permutation that handles only one browser and language, but the difference isn't significant.

You can also try few GWT compilation options which worked for me:

 -draftCompile                Enable faster, but less-optimized, compilations
 -localWorkers               The number of local workers to use when compiling permutations
 -XdisableCastChecking EXPERIMENTAL: Disables run-time checking of cast operations
 -optimize                       Sets the optimization level used by the compiler.  0=none 9=maximum.

e.g. -draftCompile -localWorkers 4 ( I gave -localWorkers as 4 because I have four processers.)

-draftCompile and -optimize don't work well togather. if you use "-optimize 9" that is suppose to optimize the code and -draftCompile seems to do just oposite of it.

-XdisableCastChecking and -optimize will make your GWT compilation slow but your GWT application will  speed up by 2-5% at run-time.

If you run the GWT compiler with the -localWorkers flag, the compiler will compile multiple permutations in parallel. This lets you use all the cores of a multi-core machine, for example -localWorkers 2 will tell the compiler to do compile two permutations in parallel. You won't get order of magnitudes differences (not everything in the compiler is parallelizable) but it is still a noticeable speedup if you are compiling multiple permutations.

Look at following screen shot for more information:


For more information look at GWT Compiler Options.

I also did extra bit of tweak which would  be basic for any java guy by setting VM arguments in GWT compilation option as follows:

-Xmx1024m

Yes, it is not much but you get the idea. You can tweak according to type of JVM you are using and type of machine configuration you have like RAM, number of processors, etc...

References:
  1. Blog post on how to speed up GWT compiler: http://stackoverflow.com/questions/1011863/how-do-i-speed-up-the-gwt-compiler
  2. Collapse all property option for soft compilation: http://code.google.com/p/google-web-toolkit/wiki/SoftPermutations
  3. GWT Compiler Options: http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#DevGuideCompilerOptions

Comments

Popular posts from this blog

How to enable internet access from Android emulator using proxy?

How to use Fork/Join Framework's RecursiveAction feature in JDK7?