[ https://issues.apache.org/jira/browse/GROOVY-10207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun closed GROOVY-10207. ------------------------------- Fix Version/s: (was: 4.x) Resolution: Won't Fix Most of Groovy4 bytecodes consist of invokedynamic, only some legacy parts are still using reflection, we will tweak the bytecode finally. For groovy pre-4, the improvement is too big to fit the maintainence releases. > Improve the performance of method invocation with MethodHandle > -------------------------------------------------------------- > > Key: GROOVY-10207 > URL: https://issues.apache.org/jira/browse/GROOVY-10207 > Project: Groovy > Issue Type: Improvement > Reporter: Daniel Sun > Priority: Major > > *Rationale* > 1. Generate {{FastMethod}} subclass whose field holds {{MethodHandle}} > instanceĀ at runtime > 3. Invoke method with {{FastMethod}} instance > *Tweak {{CachedMethod}} via the above way* > > [https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/reflection/CachedMethod.java] > *Simple performance test result* > Invoking {{java.lang.String#startsWith(java.lang.String)}} for 1000000 times: > direct: 13ms > reflection: 34ms > fastmethod: 10ms > As we could see, fastmethod runs as almost fast as direct calls, andĀ > fastmethod runs about 3 times faster than reflection > *Reference* > > [https://www.optaplanner.org/blog/2018/01/09/JavaReflectionButMuchFaster.html] -- This message was sent by Atlassian Jira (v8.3.4#803005)