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

Use LambdaMetafactory instead of classic reflection whenever possible #160

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

breitwan
Copy link
Contributor

@breitwan breitwan commented Aug 7, 2024

LambdaMetafactory 10% slower than a static MethodHandle but 80% faster than a non-static MethodHandle & Reflection

Replaced frequent reflection call to the constant field DEFAULT_PERMISSIONS by own constant
Removed hacky use of sun.misc.Unsafe from LoginListener.java
LMF is not used in one-shot things like LimboProtocol.java

https://stackoverflow.com/questions/19557829/faster-alternatives-to-javas-reflection/19563000#19563000
https://www.optaplanner.org/blog/2018/01/09/JavaReflectionButMuchFaster.html
https://mail.openjdk.org/pipermail/mlvm-dev/2018-February/006817.html

@UserNugget
Copy link
Member

UserNugget commented Aug 7, 2024

Hello! Thanks for the PR, but maybe it is better to use VarHandle for current use case?
It seems that VarHandle are properly optimized by the JIT compiler these days.

Edit: nevermind, VarHandle do not really has a proper way to modify final fields.

Copy link
Member

@UserNugget UserNugget left a comment

Choose a reason for hiding this comment

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

Require some changes to build.

Copy link
Member

@UserNugget UserNugget left a comment

Choose a reason for hiding this comment

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

LGTM

@UserNugget UserNugget merged commit cace305 into Elytrium:master Aug 8, 2024
1 check passed
@UserNugget
Copy link
Member

Thanks!

@breitwan breitwan deleted the lambdametafactory branch August 8, 2024 12:43
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.

2 participants