性能調整

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 以減少 data watcher 查詢的時間。

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
      }

內聯塊位置檢查

此設置內嵌檢查一個塊的位置在世界中是否有效。

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 預設每 900 ticks (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负载和硬盘占用也会随之上升,但频繁的备份对服务器断电后的回档有帮助;与之相对的是,时间间隔越高,服务器的负载也会随之降低,但当服务器出现问题导致存档丢失后,进度损失有可能会十分巨大。