性能调优

Sponge提供了一些性能优化和其他一些额外选项,可帮助你的服务器可以在高负载下流畅运行。

注解

虽然我们想让所有服务器都流畅无比,但这还要取决于你是否正确配置服务器。下面来测试一下你的服务器是否达到了最强性能!

实体活动范围

这个设置会改变玩家身边载入的实体数。调低这个值会载入更少的实体,并且会提高服务器性能(尤其在实体数量很多时);提高则会载入更多实体。

小技巧

当然,你也可以针对某个 特定生物 设定其活动范围。你还大可以选择将 auto-populate 设定为 true ,这样 Sponge 就会帮你自动设定所有生物的活动范围,惟需注意,我们建议你在自动设定完成后关闭此选项(即重新设定为 false )。若有新的生物种类,只需重复此步骤即可。

entity-activation-range {
      # If enabled, newly discovered entities will be added to this config with
      # a default value.
      auto-populate=false

      # Default activation ranges used for all entities unless overidden.
      defaults {
          ambient=32
          aquatic=32
          creature=32
          misc=16
          monster=32
      }

缓存可驯服动物的主人

启用后,所有可驯化动物的主人的UUID都会缓存起来,以节约 DataWathcer 查询时的时间。

optimizations {
    # Caches tameable entities owners to avoid constant lookups against data watchers. If mods cause issue, disable.
    cache-tameable-owners=true
    }

预合并掉落物品

启用后,新生成的掉落物将会尽可能合并在一起,藉由此避免在短时间内刷新大量实体,以及此后合并掉落物引发的大量计算。

optimizations {
    # If enabled, block item drops are pre-processed to avoid
    # having to spawn extra entities that will be merged post spawning.
    # Usually, Sponge is smart enough to determine when to attempt an item pre-merge
    # and when not to, however, in certain cases, some mods rely on items not being
    # pre-merged and actually spawned, in which case, the items will flow right through
    # without being merged.
    drops-pre-merge=true
    }

忽略未加载区块的雷暴

启用此选项后,未加载区块中的雷暴数据不会被加载。此选项可减少区块生成时的磁盘访问量,进而提高处理方块光照时的性能。

optimizations {
      # This prevents chunks being loaded for getting light values at specific
      # block positions. May have side effects.
      ignore-unloaded-chunks-on-get-light=true
      }

区块查询缓存

启用本选项后, Sponge 会占用一部分内存用于缓存区块,进而提高服务器性能。若服务器内存不足,请禁用此选项。

optimizations {
      # Caches chunks internally for faster returns when querying at various
      # positions
      chunk-map-caching=true
      }

内联方块坐标检查

此选项将内联 (inline)检查一个方块在世界中的坐标是否有效。

optimizations{
      # Inlines a simple check for whether a BlockPosition is valid
      # in a world. By patching the check, the JVM can optimize the
      # method further while reducing the number of operations performed
      # for such a simple check. This may however break mods that alter
      # world heights and can thus be disabled in those cases.
      inline-block-position-checks=true
      }

自动调整保存时间

Minecraft官方服务器每900Tick(即45秒)就会保存一次地图。如果你想要调整这个值,可在 global.conf 文件里修改:

world {
      # The auto-save tick interval used when saving global player data.
      # Set to 0 to disable. (Default: 900) Note: 20 ticks is equivalent to 1 second.
      auto-player-save-interval=900

      # The auto-save tick interval used to save all loaded chunks in a world.
      # Set to 0 to disable. (Default: 900) Note: 20 ticks is equivalent to 1 second.
      auto-save-interval=900
      }

时间间隔越低,意味着保存频率越快,因此服务器的CPU负载和硬盘占用也会随之上升,但频繁的备份对服务器断电后的回档有帮助;与之相对的是,时间间隔越高,服务器的负载也会随之降低,但当服务器出现问题导致存档丢失后,进度损失有可能会十分巨大。