JSR-292(invokedynamic)会对 Groovy 性能产生多大影响?
是否有一个估计表明 JSR-292 对 Groovy 性能的影响有多大?
Is there an estimate that says how much JSR-292 will impact Groovy performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
invokedynamic 确实是一个复杂的故事,因为 JDK7 中的性能特征一直在变化。在将 Groovy 移植到 indy 的过程中,我真的非常非常接近 Java,大约是 1.5 倍。但我必须使用 catchExceptionGuard,这会将性能降低到大约 3-4 倍。我们仍然需要研究避免使用该警卫的方法。也许我们必须为此破坏 Groovy 2.2 中的一些现有代码。无论如何,我不需要如上所述的 invokeMethod 后备保护。对于可能包含其他异常的 GroovyRuntimeExceptions,我必须对其进行解包或执行其他操作。因此,理论上可能的性能似乎介于 Java 和现有方法的 Java 速度的一半之间。对 invokeMethod 的调用的性能是一个完全不同的故事。
如果您需要更多,请在 Groovy 2.0 中使用 @CompileStatic。
invokedynamic is a complicated story really, since the performance characteristics changes all the time in JDK7. During porting Groovy to indy I got really, really near Java, about factor 1.5. But I have to use the catchExceptionGuard, which reduces performance to something like being factor 3-4. We still need to investigate ways to avoid having to use that guard. Maybe we will have to break some existing code in Groovy 2.2 for that. Anyway, I don't need the guard for the invokeMethod fallback as mentioned above. It is for GroovyRuntimeExceptions possibly containing other exceptions, that I have to unwrap or do other things with. So the theoretical possible performance seems to be between Java and half of Java speed for existing methods. Performance of calls to invokeMethod is a whole different story.
If you need more, then use @CompileStatic in Groovy 2.0.
我认为还没有一个基准,在有人执行之前我们只能猜测......
您可能会发现 这篇文章在这件事上很有趣。
I don't think there is a benchmark yet, and until someone performs it we can only guess...
You may find this post in this matter interesting.
一般来说,速度会快 10-50 倍左右。
http://www.mail-archive.com/ [电子邮件受保护]/msg00819.html
It would be around 10-50 times faster in general.
http://www.mail-archive.com/[email protected]/msg00819.html
我不确定它在多大程度上适用于 Groovy。如果我没记错的话,Groovy 有一些后备方案(例如 invokeMethod 方法)。我认为,不可能简单地使用 invokedynamic 的回退。
但是,有一些方法:
I'm not sure how much is it applicable to Groovy. If I remember well, Groovy has some fallbacks (e.g. invokeMethod method). It is not possible to simply use the fallback with invokedynamic, I think.
However, there are some ways: