I was trying to reduce the time it takes for an ant build to complete. Most of the build time is taken by GWT compiler.
Following ant script is written on the lines of scripts found in official GWT examples. Notice how two GWT modules are being passed to the Complier. When you run this script, the GWT compiler compiles the two modules sequentially.
<target name="gwtc" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
........
........
<arg value="com.af.gwtmodules.dashboard.Dashboard" />
<arg value="com.af.gwtmodules.administration.Administration" />
<arg line=" -localWorkers 16" />
</java>
</target>
I changed the task to run 2 compile tasks in parallel and in each task I pass only one GWT module to the compiler.
<target name="gwtc" description="GWT compile to JavaScript">
<parallel threadsperprocessor="16">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
........
........
<arg value="com.af.gwtmodules.dashboard.Dashboard" />
<arg line=" -localWorkers 16" />
</java>
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
........
........
<arg value="com.af.gwtmodules.administration.Administration" />
<arg line=" -localWorkers 16" />
</java>
</parallel>
</target>
This indeed runs faster as expected. However, I wonder whether the GWT compiler can do a better job at code optimization if it is given all modules at once instead of each module separately. For example, the two modules use a lot of common code. So if the compiler can see the entire code base at once, it can find more redundant code. In theory, it can create a single JS artefact for the common code and separate JS artifacts for code that is not common. This would have the effect of reducing download time for the user who accesses both modules as common JS artifact would be downloaded only once.
As far as I understand GWT modules are independent and so there would be no cross module optimizations. But the fact that GWT compiler internally does not parallelize this makes me think that there could be some cross module optimizations or other ramifications because of which Google engineers decided against parallelizing it beyond a limit.
I would like to know if parallelizing compile the way I have done, has any effect on quality of generated code.