A Few Ways To Get Better GWT Compile Times

We have dozens of GWT modules here at GT Nexus.  To many, that statement will raise red flags and perhaps accusations of questionable architecture, but the fact is that we have a very large product suite and implementing products in their own modules is working very well for us.

The downside of this design is that compiling all our GWT modules takes a very, very long time, even on modern silicon (and germanium, etc.).

The Google Web Toolkit team is aware of how long compiles take, however their emphasis is on enhancing the user experience; if that comes at the expense of a longer compile for developers, that’s OK with them. For instance, they claim that “an extra 30 seconds of compiler time is worth it to get a 5% improvement in code size.”  I appreciate that perspective, but I also want faster compiles!

To start, there are two things that you can do with a modern multi-core machine to speed up your compiles; I do not have these in my notes from Google IO 2010, but they are well-advertised in the GWT community. Namely:

  • If you are using Ant, use the <parallel> tag to compile modules in parallel.  This can yield phenominal results.
  • Use the GWT -localWorkers argument to use multiple threads during compilation.

In addition, the GWT team recommends:

  • Use two module definitions for each module; for instance, “MyProject.gwt.xml” and “MyProjectDev.gwt.xml,” and tune the “Dev” version to compile with Pretty formatting, for one browser (if possible), and other common methods for speeding up the compiler
  • Use the -draftCompile  compiler flag to avoid complicated optimizations (for development)
  • Use pretty output for development

Their non-compiler-related suggestions are:

  • Use better hardware.
  • Use RAID/SSD
  • Use -server JVM flag and more memory

In addition, there are capabilities in the GWT compiler that have not yet been exposed or well documented.  For instance, there is support for parallelized and clustered builds by using the precompiler and certain “CompilePerms.”  See the Google IO 2010 presentation linked to below for more information on this option.

Beyond that, the old standby is to identify the modules that you are not interested in compiling and comment them out.  That is perhaps the most effective tool we currently have in our environment to speed up our compiles, short of not compiling the GWT modules at all.

The GWT compiler often works some wonderful magic, but that magic comes at the price of slow compile times.  We have had varying success with these techniques, but the GWT team appears to be aware of them and will hopefully toss us a bone in the future to help developers become even more productive with their toolkit.

Links:

About these ads

6 Responses to A Few Ways To Get Better GWT Compile Times

  1. [...] product is currently a single GWT module, however, which required us to do some investigation into methods for reducing compile times. We are developing methods for merging related modules, but the impact to client performance must [...]

  2. Simon says:

    And this is why I’m reluctant to do much with GWT. We *do* use it in our product, to the extent that it adds half an hour to a clean build, even after being made to run parallel. Better hardware isn’t exactly helpful advice – we’re already running the best quad-core workstations money could buy (as of a year ago), with a bucket-load of memory.

    And so while individual modules can be changed without too much pain, anything in common code means at least half an hour downtime just to compile, never mind running tests…

  3. Jim says:

    GWT compilation has definitely become the biggest component of our regular build cycle, and it is an issue. Structural changes, such as some of the options recommended in Ben Northrup’s article, can help this, but compiling a collection of independent modules is an issue and Google has not really come up with a good answer yet.

  4. [...] RE: Widget compiling on ant takes long! Answer (Unmark) 5/4/12 10:19 PM as a reply to Madz R. Most of the time is spent by the GWT-compiler on analyzing the sourcecode (it must look through all files to identify all dependencies) and compiling the code to all permutations – this is for all supported languages and all supported browsers. To reduce the compile-time during development, you can tell the compiler to create only one permutation: Your favorite language in your favorite browser. For achieving this, you need to edit your widgetset-definition; add the following line to only compile for Firefox:1<set-property name="user.agent" value="gecko1_8" />More tricks might be found here. [...]

  5. [...] productivity to require the continuous compilations of a 50,000+ LOC client library with the not exactly lightning fast GWT compiler. I therefore plan to provide a precompiled JavaScript client library rather than a GWT [...]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: