Am 10.01.20 um 16:14 schrieb Daniel.Sun:
Hi Jochen,

     > If you want to get the maximum performance then I would suggest to
work
with the guards instead of falling back to a hashed map.

     Thanks for your suggestions :-)

     After we constructed the following "tree" MH with guards, we have to set
target to link the MH to the related callsite.

       Guard(String)
       /          \
MH(same(String)    Guard(Float)
                    /          \
        MH(same(float))      Guard(Integer)
                             /           \
                 MH(same(int))        Fallback to select


     But the "setTarget" may cause poor performance because JVM may do some
de-opt shown as GROOVY-8298:

nothing goes beyond a test. Really, to be deopt, there has to be an
optimization first. The tests we did do not reflect this. You have to
change the examples to something like:

def same(String obj) { return obj }
def same(int obj) { return obj }
def same(float obj) { return obj }
for (r in [1, 1.0f, '1.0']) {
  for (int i = 0; i < 100_000; i++) {
    r.each { same(it) }
  }
}


```
"qtp2078714399-360525": running, holding [771bcf60]
        at java.lang.invoke.MethodHandleNatives.setCallSiteTargetNormal(Native
Method)
        at java.lang.invoke.CallSite.setTargetNormal(CallSite.java:258)
        at java.lang.invoke.MutableCallSite.setTarget(MutableCallSite.java:154)
        at
org.codehaus.groovy.vmplugin.v7.Selector$MethodSelector.doCallSiteTargetSet(Selector.java:909)
        at
org.codehaus.groovy.vmplugin.v7.Selector$MethodSelector.setCallSiteTarget(Selector.java:969)
        at
org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:228)
        at
java.lang.invoke.LambdaForm$DMH/1665404403.invokeStatic_L3IL5_L(LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$BMH/1828868503.reinvoke(LambdaForm$BMH)
        at
java.lang.invoke.LambdaForm$reinvoker/1917025677.dontInline(LambdaForm$reinvoker)
        at java.lang.invoke.LambdaForm$MH/462773420.guard(LambdaForm$MH)
        at 
java.lang.invoke.LambdaForm$MH/1947020920.linkToCallSite(LambdaForm$MH)
```

How did you produce that trace?

bye Jochen

Reply via email to