我如何加速gwt编译器? [英] How do I speed up the gwt compiler?

查看:169
本文介绍了我如何加速gwt编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开始在我们的项目中更多地使用GWT,并且GWT编译器的性能变得越来越令人讨厌。

我们将开始改变我们的工作实践以缓解问题,包括更加重视托管模式浏览器,该浏览器推迟运行GWT编译器直到晚些时候,但它带来了自己的风险,尤其是在真正的浏览器中没有捕捉到问题,直到晚于我们想要的时间。



理想情况下,我们会就像让GWT编译器本身更快一样 - 编写一个相当小的应用程序的一分钟就会带来麻烦。但是,如果我们使用的是相当天真的方式进行编译,那么我希望我们可以快速轻松地获得收益。



我们目前正在调用com.google .gwt.dev.Compiler作为来自Ant Ant目标的Java应用程序,具有256m最大堆和大量堆栈空间。编译器由Ant使用fork = true和最新的Java 6 JRE启动,试图利用Java6的改进性能。我们将主控制器类与应用程序类路径一起传递给编译器,然后关闭。



我们还可以做些什么来获得额外的速度?我们可以给它更多的信息,所以它花费更少的时间来发现做什么吗?



我知道我们可以告诉它只编译一个浏览器,但我们需要做多浏览器测试,所以这是不实际的。



所有的建议都欢迎在这一点上。

解决方案

让我们从不舒服的真相开始:GWT编译器的性能真的很糟糕。你可以在这里或那里使用一些黑客,但你不会得到明显更好的性能。



你可以做的一个很好的性能攻击是仅针对特定浏览器进行编译通过在 gwt.xml 中插入以下行:

 < ; define-property name =user.agentvalues =ie6,gecko,gecko1_8>< / define-property> 

或gwt 2.x语法,仅适用于一个浏览器:

 < set-property name =user.agentvalue =gecko1_8/> 

例如,这将只针对IE和FF编译您的应用程序。如果您知道您只使用特定的浏览器进行测试,那么您可以使用这个小黑客。

另一个选项:如果您使用多个语言环境,并且只使用一个对于测试,您可以将它们全部注释掉,以便GWT将使用默认语言环境,这会减少编译时的一些额外开销。



底线:您不是在编译器性能上会有数量级的增长,但是需要放松一些,你可以在这里和那里削减几分钟。


We're starting to make heavier use of GWT in our projects, and the performance of the GWT compiler is becoming increasingly annoying.

We're going to start altering our working practices to mitigate the problem, including a greater emphasis on the hosted-mode browser, which defers the need to run the GWT compiler until a later time, but that brings its own risks, particularly that of not catching issues with real browsers until much later than we'd like.

Ideally, we'd like to make the GWT compiler itself quicker - a minute to compile a fairly small application is taking the piss. However, we are using the compile if a fairly naive fashion, so I'm hoping we can make some quick and easy gains.

We're currently invoking com.google.gwt.dev.Compiler as a java application from ant Ant target, with 256m max heap and lots of stack space. The compiler is launched by Ant using fork=true and the latest Java 6 JRE, to try and take advantage of Java6's improved performance. We pass our main controller class to the compiler along with the application classpath, and off it goes.

What else can we do to get some extra speed? Can we give it more information so it spends less time doing discovery of what to do?

I know we can tell it to only compile for one browser, but we need to do multi-browser testing, so that's not really practical.

All suggestions welcome at this point.

解决方案

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.

这篇关于我如何加速gwt编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆