jonnybot0 commented on code in PR #2374:
URL: https://github.com/apache/groovy/pull/2374#discussion_r2747798362
##########
src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java:
##########
@@ -940,9 +941,18 @@ public void setGuards(Object receiver) {
}
}
- // handle constant metaclass and category changes
- handle = switchPoint.guardWithTest(handle, fallback);
- if (LOG_ENABLED) LOG.info("added switch point guard");
+ // Skip the global switchpoint guard by default.
+ // The switchpoint causes ALL call sites to fail when ANY
metaclass changes.
+ // In Grails and similar frameworks with frequent metaclass
changes, this causes
+ // massive guard failures and performance degradation.
+ // The other guards (metaclass identity, class receiver, category)
should be
+ // sufficient, combined with cache invalidation on metaclass
changes.
+ //
+ // If you need strict metaclass change detection, set
groovy.indy.switchpoint.guard=true
+ if (SystemUtil.getBooleanSafe("groovy.indy.switchpoint.guard")) {
Review Comment:
The one question I have about this is whether this check ought to be
inverted. That is, should the default behaviour be the old way, which we know
is less performant but more battle-tested, or this way? Could Grails simply
turn this flag on by default, thus solving their problem, without impacting
other users?
Also, as a nitpicky thing, I reckon this string ought to be a `public static
final` field so that we could add some tests around it.
--
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]