OpenJ9
OpenJ9 是完全重新设计的 JVM,拥有独立的垃圾回收系统,与 HotSpot JVM 的 G1GC、ZGC 等完全不同。
Paper 兼容性修复
Section titled “Paper 兼容性修复”如需在 Paper 及其分支上使用 OpenJ9,需禁用内置 Spark:
方法一:配置文件(推荐)
Section titled “方法一:配置文件(推荐)”在 config/paper-global.yml 中设置:
spark: enabled: false方法二:启动参数
Section titled “方法二:启动参数”添加参数:
-Dpaper.preferSparkPlugin=true-XX:+IdleTuningGcOnIdle -XX:+UseAggressiveHeapShrink -XX:-OmitStackTraceInFastThrow -XX:+UseFastAccessorMethods -XX:+OptimizeStringConcat -Xshareclasses:allowClasspaths -Xshareclasses:cacheDir=./cache -Xaot -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=256 -Xshareclasses -XX:SharedCacheHardLimit=800M -Xtune:virtualized -XX:+TieredCompilation -XX:InitialTenuringThreshold=5 -Dlog4j2.formatMsgNoLookups=true -XX:-DisableExplicitGC垃圾回收策略
Section titled “垃圾回收策略”OpenJ9 使用 -Xgcpolicy 参数来指定垃圾回收策略,而不是 HotSpot 的 -XX:+UseG1GC 或 -XX:+UseZGC。
推荐策略:gencon(默认)
Section titled “推荐策略:gencon(默认)”适合大多数 Minecraft 服务器场景,特别是有大量短生命周期对象的事务性应用。
-Xgcpolicy:gencon其他可选策略
balanced 策略
Section titled “balanced 策略”适合大堆内存(仅 64 位),能够平衡暂停时间并减少碎片化。
-Xgcpolicy:balancedoptavgpause 策略
Section titled “optavgpause 策略”优化平均暂停时间,适合对延迟敏感的应用。
-Xgcpolicy:optavgpauseoptthruput 策略
Section titled “optthruput 策略”优化吞吐量,适合能容忍较长 GC 暂停的应用。
-Xgcpolicy:optthruputmetronome 策略
Section titled “metronome 策略”提供确定性的短暂停时间(仅 Linux x86-64 和 AIX)。
-Xgcpolicy:metronome