Elytrium / LimboAPI

An API which provides virtual servers features to Velocity
https://elytrium.net/
GNU Affero General Public License v3.0
241 stars 65 forks source link

Use LambdaMetafactory instead of classic reflection whenever possible #160

Closed breitwan closed 3 months ago

breitwan commented 3 months ago

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 commented 3 months ago

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.

UserNugget commented 3 months ago

Thanks!