The postings on this site are the contributor's and don’t necessarily represent IBM’s positions, strategies or opinions.
November 27th, 2008 Alex Moffat Posted in GWT | 6 Comments »
For Blueprint we use Ant to invoke the GWT compiler even though the rest of the build process is controlled by maven. If you’re also using Ant the technique I describe is a simple way to get a nice reduction in compilation time.
In our build.xml file we have a generic CompileGWTModule target that is invoked multiple times with the antcall task to compile the different GWT modules in the application. So we end up with something like this
<antcall target="CompileGWTModule">
<param name="gwt.module" value="LoginPage"/>
</antcall>
<antcall target="CompileGWTModule">
<param name="gwt.module" value="ProcessPage"/>
</antcall>
<antcall target="CompileGWTModule">
<param name="gwt.module" value="ProjectPage"/>
</antcall>
....
On my MacBook Pro the GWT compilation process takes about eight minutes to complete when building all pages for all browsers. On my desktop it takes about seven and three quarter minutes. Ant has a parallel task that will invoke the tasks it surrounds in parallel. I simply wrapped the calls to CompileGWTModule in a parallel element like this
<parallel threadsPerProcessor="1">
<antcall target="CompileGWTModule">
<param name="gwt.module" value="LoginPage"/>
</antcall>
<antcall target="CompileGWTModule">
<param name="gwt.module" value="ProcessPage"/>
</antcall>
<antcall target="CompileGWTModule">
<param name="gwt.module" value="ProjectPage"/>
</antcall>
....
</parallel>
The threadsPerProcessor attribute tells the task to use one thread for each processor/core in the machine. With these settings the same compilation takes about four and a quarter minutes on the dual core MacBook and two and three quarter minutes on the four core desktop. That’s significantly quicker.
Of course for maximum reduction in compilation time you should also
November 27th, 2008 at 3:20 pm
Interesting!
I was thinking about a way to skip the Javascript generation completely. For hosted mode you only need your public content, the bootstrap js file (an old copy will do), history.html, hosted.html and RPC serialization files.
The later are the problem as you need real ones matching your current RPC server endpoints. But hosted mode will never look at the generated Javascript files containing the compiled client code.
It would be nice if the compiler had a ‘-bare_minimim_for_hosted_mode’ option and skip all Javascript generation. If you know your are in the middle of development and will use hosted mode exclusively thats all you need. If you want to you could press the Compile button in hosted mode later…
Christian
November 27th, 2008 at 9:31 pm
Hosted mode is probably not far off that now. I know it only generates a permutation for the single user agent value for the embedded browser it’s using. It probably also generates the RPC serialization files. I’m not sure it does any JavaScript generation, or that it actually needs any. It would be an interesting topic to investigate.
April 23rd, 2009 at 8:35 pm
[...] see what effect this has on compile times for Blueprint. The compile process for Blueprint already compiles multiple pages in parallel using the ant parallel task so it’s interesting to see how this interacts with parallel compilation of multiple [...]
July 13th, 2009 at 3:01 pm
[...] and the presence of two GWT modules plus another build compelled me to resurect some old-school Ant parallelization to stack as much work as possible during the build. With a bit of tweaking it’s easy to have [...]
August 24th, 2009 at 9:58 am
Thanks!
June 4th, 2010 at 1:42 pm
[...] Lombardi’s take on parallel and local threads [...]