Optimize netty epoll packet sending

TeaCon now uses Arclight, so we have a chance to experience heavy loads.
Per TeaCon profiling results packet sending uses a native call to wakeup threads which can take up to 20% tick time. This should work fine as server will do a flush per tick.
This commit is contained in:
IzzelAliz 2022-05-02 20:01:00 +08:00
parent 91af85d335
commit 8df52d958d
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,18 @@
package io.izzel.arclight.common.mixin.optimization.general;
import io.netty.util.concurrent.AbstractEventExecutor;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Slice;
@Mixin(Connection.class)
public class ConnectionMixin_Optimize {
@ModifyArg(method = "sendPacket", at = @At(value = "INVOKE", remap = false, target = "Lio/netty/channel/EventLoop;execute(Ljava/lang/Runnable;)V"),
slice = @Slice(from = @At(value = "INVOKE", remap = false, target = "Lio/netty/channel/EventLoop;inEventLoop()Z")))
private Runnable arclight$useLazyRunnable(Runnable runnable) {
return (AbstractEventExecutor.LazyRunnable) runnable::run;
}
}

View File

@ -6,6 +6,7 @@
"compatibilityLevel": "JAVA_11",
"mixins": [
"ClassInheritanceMultiMapMixin",
"ConnectionMixin_Optimize",
"EntityDataManagerMixin_Optimize",
"GoalMixin",
"MobMixin_Optimization",