9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-29 11:59:24 +00:00

Optimize NonFlush Packet Sending

This commit is contained in:
Taiyou06
2025-03-26 18:08:18 +01:00
parent 1e36d848c2
commit bb9f3a5600
3 changed files with 90 additions and 30 deletions

View File

@@ -1,30 +0,0 @@
package org.dreeam.leaf.config.modules.network;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
public class ConnectionFlushQueueRewrite extends ConfigModules {
public String getBasePath() {
return EnumConfigCategory.NETWORK.getBaseKeyName();
}
public static boolean enabled = false;
@Override
public void onLoaded() {
enabled = config.getBoolean(getBasePath() + ".connection-flush-queue-rewrite", enabled, config.pickStringRegionBased("""
This replaces ConcurrentLinkedQueue with ArrayDeque for better performance
and uses the Netty event loop to ensure thread safety.
May increase the Netty thread usage and requires server restart to take effect
Default: false
""",
"""
此选项将 ConcurrentLinkedQueue 替换为 ArrayDeque 以提高性能,
并使用 Netty 事件循环以确保线程安全。
默认值: false
"""));
}
}

View File

@@ -0,0 +1,35 @@
package org.dreeam.leaf.config.modules.network;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
public class OptimizeNonFlushPacketSending extends ConfigModules {
public String getBasePath() {
return EnumConfigCategory.NETWORK.getBaseKeyName();
}
public static boolean enabled = false;
@Override
public void onLoaded() {
enabled = config.getBoolean(getBasePath() + ".OptimizeNonFlushPacketSending", enabled, config.pickStringRegionBased("""
WARNING: This option is NOT compatible with ProtocolLib and may cause
issues with other plugins that modify packet handling.
Optimizes non-flush packet sending by using Netty's lazyExecute method to avoid
expensive thread wakeup calls when scheduling packet operations.
Requires server restart to take effect.
""",
"""
警告:此选项与 ProtocolLib 不兼容,并可能导致与其他修改数据包
处理的插件出现问题。
通过使用 Netty 的 lazyExecute 方法来优化非刷新数据包的发送,
避免在调度数据包操作时进行昂贵的线程唤醒调用。
需要重启服务器才能生效。
"""));
}
}