How do I speed up the gwt compiler?
Let's start with the uncomfortable truth: GWT compiler performance is really lousy. You can use some hacks here and there, but you're not going to get significantly better performance.
A nice performance hack you can do is to compile for only specific browsers, by inserting the following line in your gwt.xml
:
<define-property name="user.agent" values="ie6,gecko,gecko1_8"></define-property>
or in gwt 2.x syntax, and for one browser only:
<set-property name="user.agent" value="gecko1_8"/>
This, for 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.
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.
Bottom line: you're not going to get order-of-magnitude increase in compiler performance, but taking several relaxations, you can shave off a few minutes here and there.
Errai (GWT) compilation is too slow -- how to make is faster
First you can set it to build for one browser only. Add this to the modules '.gwt.xml' file:
<set-property name="user.agent" value="gecko1_8"/>
(Other user agents can be found here https://gwt.googlesource.com/gwt/+/master/user/src/com/google/gwt/useragent/UserAgent.gwt.xml)
Another optimisation is to let gwt use more than one core when building. When you 'GWT Compile', on the advanced under 'Additional compiler options' add:
-localWorkers -8
Or the amount of thread you want to use.
Lastly, if your project contains multiple modules, each with their own entry points. You do not have to rebuild each one of them every time. Only the one you are working on. I have a project with 15+ modules and only build one at a time unless I have made a change to shared data in another module.
It's just as easy to remove modules from the 'GWT Compile' as it is to add them.
With the above being used you will get a build time of between 5 and 15 seconds.
speed up gwt compiling process
Add the param -localWorkers
. This specifies that the permutations are done in parallel. Especially on a multicore machine this makes sense. The parameter for the argument is the number of parallel runs. I tested several combinations and found that 4
gave the best results(fastest, even while i tested it on a 6 core/12GB machine). So just try out what works best in your situation, also experiment with the memory value. for example try 512 instead of 256.
<arg value="-localWorkers" />
<arg value="4" />
A second option is -draftCompile
. This skips some compile optimizations, so it's not an option you want to use for the production release. But in development it saves compilation time.
Or buy a faster machine;-) processor speed matters in this case
Larg GWT Project and compile time problem
The GWT compiler is inherently slow. Konoplianko provided some optimizations in his answer, but this will only go so far. There are 2 more compiler options that will help. You can play around with the number of worker threads, usually going from 1 to 2 will help and sometimes 3, but depending on your system it will hurt compile time when you get above a certain point(usually 3 in my experience). Also you can use the -draftCompile option if you are using 2.1. GWT was architected with the intention that you only compile when you intend to deploy something not during development. It was intended that you use hosted mode for development because it can keep track of what has changed and only recompile what is needed instead of having to recompile everything. I am not sure if it would help but changing the output from OBF to DETAILED or vice-versa might effect compile time.
Related Topics
Building Executable Jar with Maven
Filter Jacoco Coverage Reports with Gradle
Return Generated PDF Using Spring MVC
How to Find a Whole Word in a String in Java
Maven Is Not Working in Java 8 When Javadoc Tags Are Incomplete
Why Does Concurrenthashmap Prevent Null Keys and Values
Java: How to Compile an Entire Directory Structure of Code
Why Does My Sorting Loop Seem to Append an Element Where It Shouldn'T
Fill' Unicode Characters in Labels
Difference in System. Exit(0) , System.Exit(-1), System.Exit(1 ) in Java
How to Format a Java String with Leading Zero
Embed a Jre in a Windows Executable
Jsf Convertdatetime Renders the Previous Day
How to Configure Jackson in Wildfly
Executors.Newcachedthreadpool() Versus Executors.Newfixedthreadpool()