Monday, May 13, 2013

Increase GWT compilation time



                      Many people say GWT takes long for compilation and reduces our development time. There are few options which you can try it!!

Reducing Permutations


                       By default, GWT compiles your application for all browsers. GWT spends time to compute permutations : create javascript file per browser/locale. If you have 5 browsers and 3 locales, GWT uses 15 permutations.


You can use some hacks here and there. A nice performance hack you can do is to compile for only specific browsers, by inserting the following line in your gwt.xml:
<set-property name="user.agent" value="gecko1_8"/>

This example, will compile your application for IE and FF only. If you know you are using only a specific browser for testing, you can use this little hack.
You can see list of user agents here
Another option: if you are using several locales, and again using only one for testing, you can comment them all out so that GWT will use the default locale, this shaves off some additional overhead from compile time.
In the newer versions of GWT (starting either 2.3 or 2.4, i believe), you can also add
<collapse-all-properties />
to your gwt.xml for development purposes. That will tell the GWT compiler to create a single permutation which covers all locales and browsers. Therefore, you can still test in all browsers and languages, but are still only compiling a single permutation

Increase local workers          

                  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 paralleled)  but it is still a noticeable speedup if you are compiling multiple permutations.

Using draftCompile 

                 As per spec -draftCompile which enables compilation faster, but less-optimized compilations -optimize 0 which does not optimize your code (9 is the max optimization value). Best suits for testing environment. 

Controlling Permutation

              GWT offical doc is detailed this approach. 





No comments:

Post a Comment