Is there an estimate that says how much JSR-292 will impact Groovy performance?
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.
It would be around 10-50 times faster in general.
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:
- Catch the exception that is thrown when the method is not found. Unfortunately, it is probably necessary to analyze stacktrace, because you can't be sure where is it thrown from. This can be a signifficant slowdown when calling a non-existing method, regardless it is handled by invokeMethod callback.
- Look at Groovy++. It allows you to use static typing if you satisfy some contraints. In such case, the it can be possible to allow you to switch to a "strict dynamic mode", which does not allow these fallbacks.
© 2022 - 2024 — McMap. All rights reserved.
com.athaydes.ml.algorithms.LinearGPTest::testNonTrivialPrograms
. It runs in 4 seconds normally, but with groovy-indy and invokedynamic, it runs in at least 25 seconds. – Xhosa