Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid slow Class.forName when serializing lambdas #944

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

theigl
Copy link
Collaborator

@theigl theigl commented Mar 22, 2023

This PR improves the performance of ClosureSerializer by avoiding calls to Class.forName whenever possible.

The change requires a reflective call to a private field in SerializedLambda, but since we already reflect into this class to get access to the readResolve method, I don't think this is an issue.

The new implementation is 2.5-3x faster:

Benchmark Mode Cnt Score Error Units
ClosureSerializerBenchmark.new thrpt 3 2816003 ± 1112830,503 ops/s
ClosureSerializerBenchmark.old thrpt 3 1134271 ± 61452,742 ops/s

@theigl theigl self-assigned this Mar 22, 2023
@theigl theigl merged commit cd5980b into master Mar 27, 2023
@theigl theigl deleted the closure-serializer-perf branch March 27, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant