Minecraft服务器优化指南
本优化基于支持Bukkit,spigot等的支持插件及更详细配置的服务端。
对于纯fabric和forge,配置文件项大部分内容都不适用。
PAPER PUFFERFISH PURPUR待更新
JAVA部分
JAVA11
使用https://dragonwell-jdk.io/#/index
搭配以下jvm参数:
JAVA
java -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
-XX:+UseFMA -XX:+UseVectorCmov -XX:+UseNewLongLShift -XX:+UseFastStosb
-XX:+SegmentedCodeCache -XX:+OptimizeStringConcat -XX:+DoEscapeAnalysis -XX:+OmitStackTraceInFastThrow -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:-DontCompileHugeMethods -XX:MaxNodeLimit=240000 -XX:NodeLimitFudgeFactor=8000 -XX:+UseVectorCmov -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:ThreadPriorityPolicy=1 -XX:+UseZGC -XX:AllocatePrefetchStyle=1 -XX:-ZProactive
JAVA17
使用https://www.graalvm.org/
搭配以下JVM参数:
JAVA
java -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseFMA -XX:+UseVectorCmov -XX:+UseNewLongLShift -XX:+UseFastStosb -XX:+SegmentedCodeCache -XX:+OptimizeStringConcat -XX:+DoEscapeAnalysis -XX:+OmitStackTraceInFastThrow -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:AllocatePrefetchStyle=3 -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:-DontCompileHugeMethods -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.TuneInlinerExploration=1 -XX:+UseZGC -XX:AllocatePrefetchStyle=1 -XX:-ZProactive
JAVA21
使用https://www.graalvm.org/
搭配以下JVM参数:
JAVA
java -Xms8G -Xmx8G -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseZGC -XX:-ZUncommit -XX:-ZProactive -Dterminal.jline=false -Dterminal.ansi=true -Djline.terminal=jline.UnsupportedTerminal -Dlog4j2.formatMsgNoLookups=true -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseNUMA -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.TuneInlinerExploration=1 -XX:+ParallelRefProcEnabled -XX:InitiatingHeapOccupancyPercent=15 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -XX:-UseBiasedLocking -XX:+UseStringDeduplication -XX:+UseAES -XX:+UseAESIntrinsics -XX:+UseFMA -XX:+UseLoopPredicate -XX:+RangeCheckElimination -XX:+EliminateLocks -XX:+DoEscapeAnalysis -XX:+UseCodeCacheFlushing -XX:+SegmentedCodeCache -XX:+UseFastJNIAccessors -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseThreadPriorities -XX:+OmitStackTraceInFastThrow -XX:+TrustFinalNonStaticFields -XX:ThreadPriorityPolicy=1 -XX:+UseInlineCaches -XX:+RewriteBytecodes -XX:+RewriteFrequentPairs -XX:-DontCompileHugeMethods -XX:+UseFPUForSpilling -XX:AllocatePrefetchStyle=3 -XX:+UseFastStosb -XX:+UseNewLongLShift -XX:+UseVectorCmov -XX:+UseXMMForArrayCopy -XX:+UseXmmI2D -XX:+UseXmmI2F -XX:+UseXmmLoadAndClearUpper -XX:+UseXmmRegToRegMoveAll -XX:+UseLargePages -XX:LargePageSizeInBytes=2M -DPaper.IgnoreJavaVersion=true -Dfile.encoding=UTF-8 -Xlog:async -Djava.security.egd=file:/dev/urandom —add-modules jdk.incubator.vector -jar server.jar –-nogui
如果运行出现问题,使用以下兼容版本的JVM参数
JAVA
java -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseFMA -XX:+UseVectorCmov -XX:+UseNewLongLShift -XX:+UseFastStosb -XX:+SegmentedCodeCache -XX:+OptimizeStringConcat -XX:+DoEscapeAnalysis -XX:+OmitStackTraceInFastThrow -XX:+AlwaysActAsServerClassMachine -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:AllocatePrefetchStyle=3 -XX:NmethodSweepActivity=1 -XX:ReservedCodeCacheSize=400M -XX:NonNMethodCodeHeapSize=12M -XX:ProfiledCodeHeapSize=194M -XX:NonProfiledCodeHeapSize=194M -XX:-DontCompileHugeMethods -XX:+PerfDisableSharedMem -XX:+UseFastUnorderedTimeStamps -XX:+UseCriticalJavaThreadPriority -XX:+EagerJVMCI -Dgraal.TuneInlinerExploration=1 -XX:+UseZGC -XX:AllocatePrefetchStyle=1 -XX:+ZGenerational
配置文件部分
此处提到的参数都对性能影响较大,影响低及不明的未列出,只需修改提到的参数即可。
SERVER.PROPERTIES
SERVER.PROPERTIES
simulation-distance #默认10,最低5
view-distance #默认10
BUKKIT.YML
BUKKIT.YML
spawn-limits #默认值: monsters:70, animals:10, water-animals:15, water-ambient:20, ambient:15
推荐值:monsters:25~55, animals:5~8, water-animals:3~7, water-ambient:5~10, ambient:1~8 //怪物刷新限制
chunk-gc.period-in-ticks #默认值: 600 推荐值: 400 //空块卸载间隔刻度
ticks-per.(type)-spawns #默认值: Monster:1,water:1,water-ambient:1,ambient:1
推荐值:monster:2~5,water:3~11,water-ambient:10~20,ambient:8~20 //怪物刷新频率(tick)
SPIGOT.YML
SPIGOT.YML
mob-spawn-range #默认值:8 推荐值:视野范围-1 //怪物生成范围
entity-activation-range #默认值: animals:32, monsters:32, raiders: 48, misc:16
推荐值:animals:20-, monsters:28-, raiders: 48, misc:12- //怪物活跃距离
merge-radius #默认值: item:2.5, exp:3.0 推荐值: item:3.0+, exp:5.0+ //地面物品堆叠范围
插件部分(仅常用插件及常用指令)
Chunky 区块预生成
/chunky radius xxx 设置生成距离
/chunky start 开始生成
/chunky pause 暂停并保存
/chunky continue 继续上次的生成
/chunky cancel 取消当前任务
/chunky world xxx 选择生成世界
Eclean 扫地
Luckperm 权限管理
/lp editor [type] [filter] 在线编辑权限
另还有Sakuya在用的不错的功能插件:
Imageframe 自定义画
Coreprotect 区块/物品保护插件
模组部分
Spark
/spark profiler stop 生成性能分析报告
observable
游戏内GUI操作