Skip to content

Conversation

@rpuch
Copy link
Contributor

@rpuch rpuch commented Jan 18, 2022

https://issues.apache.org/jira/browse/IGNITE-16258

Switched from MethodHandle to Method, because in the non-static case Method performs better than MethodHandle

Benchmark                                                                       Mode  Cnt   Score   Error  Units
MethodVsMethodHandleBenchmark.directInexactMethodHandleReturningNewObject       avgt   15   8,130 ± 0,371  ns/op
MethodVsMethodHandleBenchmark.directInexactMethodHandleReturningSelf            avgt   15   6,322 ± 0,076  ns/op
MethodVsMethodHandleBenchmark.directExactMethodHandleReturningNewObject         avgt   15  11,203 ± 3,175  ns/op
MethodVsMethodHandleBenchmark.directExactMethodHandleReturningSelf              avgt   15  10,601 ± 0,221  ns/op
MethodVsMethodHandleBenchmark.empty                                             avgt   15   4,441 ± 0,058  ns/op
MethodVsMethodHandleBenchmark.methodReturningNewObject                          avgt   15  14,832 ± 0,377  ns/op
MethodVsMethodHandleBenchmark.methodReturningSelf                               avgt   15   5,359 ± 0,074  ns/op
MethodVsMethodHandleBenchmark.unreflectedInexactMethodHandleReturningNewObject  avgt   15   8,691 ± 1,347  ns/op
MethodVsMethodHandleBenchmark.unreflectedInexactMethodHandleReturningSelf       avgt   15   8,661 ± 2,511  ns/op
MethodVsMethodHandleBenchmark.unreflectedExactMethodHandleReturningNewObject    avgt   15  13,074 ± 0,172  ns/op
MethodVsMethodHandleBenchmark.unreflectedExactMethodHandleReturningSelf         avgt   15  10,476 ± 0,162  ns/op

Also, MethodHandle does not work for calling SerializedLambda#readResolve().

}

static boolean isLambda(Class<?> objectClass) {
return objectClass.getSimpleName().contains("$$Lambda$") && objectClass.isSynthetic()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this "$$Lambda$" is JVM specific

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's JVM specific. Actually, when checking for a lambda here, we actually want to know that the class cannot be loaded by name, so it makes sense to check this property directly.

Reworked the fix to detect whether we can load the class by name (and that it's not a primitive or an array); along with isSynthetic() it should yield the correct result.

@semyon
Copy link

semyon commented Jan 19, 2022

Gentlemen, I think you've tagged a wrong Semyon :)

@rpuch
Copy link
Contributor Author

rpuch commented Jan 19, 2022

@semyon Indeed, sorry for that :)

rpuch added 3 commits January 19, 2022 15:33
…Serialization

- switch back to Method (instead of MethodHandle) to invoke special serialization methods as MethodHandle invocation fails for SerializedLambda#readResolve() (while Method works fine), and it turns out that for the case when our Method/MethodHandles are not static, Method performs better than MethodHandle
…Serialization

- do not detect lambda classes by name; instead, check that they cannot be loaded by name
Copy link
Contributor

@SammyVimes SammyVimes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SammyVimes SammyVimes merged commit 4f8f7ae into apache:main Jan 19, 2022
@SammyVimes SammyVimes deleted the ignite-16258 branch January 19, 2022 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants