blackdrag commented on issue #15293: URL: https://github.com/apache/grails-core/issues/15293#issuecomment-3757269419
> **Enhance caching for per-instance metaclasses:** In Selector.java, the cache &= !hasPerInstanceMetaClasses is conservative. Add an optional guard (e.g., instance-specific metaclass check) or a property -Dgroovy.indy.cache.perinstance=true to enable caching with extra safeguards. This could help GORM-like apps without breaking dynamics. I agree that this area needs improvement. If we keep the switchpoint, then we could actually allow MetaClassImpl as per instance meta class. What we need is something telling me the meta class is constant = no usage before it is complete and then does no longer change, a change means setting a new metaclass. We could cache getMetaClass(receiver) and add sameMC as guard. If mc is no MetaClassImpl, we call always mc.invoke(name,args). Otherwise we can do method selection and save the selection. If no method is found but the receiver is GroovyObject, then we call receiver.invokeMethod. Otherwise also mc.invokeMethod. Unless a specific method has been selected, we do not check the argument classes in a guard. If we get the metaclass every time anyway, we actually also do not need the switchpoint. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
