增量玩家数据保存
一款用于消除 Minecraft 服务器中因玩家数据自动保存而导致的 MSPT(每刻毫秒数)突增的模组。
功能说明
Minecraft 的自动保存机制会在每个保存间隔调用一次 net.minecraft.server.PlayerManager.saveAllPlayerData(),在一个游戏刻内将所有在线玩家的数据写入磁盘。对于玩家数量较多或玩家数据量较大的服务器,这会导致显著的 MSPT 突增。
Incremental Player Save 通过将玩家数据的保存分散到多个游戏刻中来解决此问题,每个游戏刻只保存少量玩家的数据,而不是一次性全部保存。该模组的灵感来源于 Paper 的增量玩家保存功能。
适用人群
如果你遇到以下情况,请安装此模组:
- 每隔自动保存间隔(默认:每 6000 刻 / 5 分钟)出现规律的 MSPT 突增
- 在 Spark 分析器结果中,突增期间出现了
net.minecraft.server.PlayerManager.saveAllPlayerData
本模组仅针对玩家 .dat 文件的写入操作进行优化。它无法减少来自区块保存或其他自动保存任务的突增。
配置
所有选项均位于模组的配置文件 config/incrementalplayersave.json 中。
| 选项 |
描述 |
默认值 |
ticksBetweenSaveAttempts |
模组检查哪些玩家需要保存的时间间隔(以刻为单位) |
20 |
ticksBetweenSavesPerPlayer |
单个玩家两次保存之间的最小时间间隔(以刻为单位) |
6000 |
maxPlayersSavedPerAttempt |
每次尝试保存的最大玩家数量。控制每刻的保存开销 |
3 |
enableDebugLog |
将保存操作记录到控制台日志 |
false |
其他说明
-
部分优化模组可能包含类似的功能。在安装之前,请使用 Spark 确认你的性能分析报告中是否仍然存在 saveAllPlayerData。在我的服务器上,即使安装了 Lithium 等众多优化模组,它们都未能缓解由 PlayerManager.saveAllPlayerData() 引起的刻延迟突增。
-
在 Mojang Mappings 映射下,net.minecraft.server.PlayerManager.saveAllPlayerData() 对应的是 net.minecraft.server.players.PlayerList.saveAll()。
Incremental Player Save
A mod to eliminate MSPT spikes caused by player data auto-save on Minecraft servers.
What It Does
Minecraft's auto-save calls net.minecraft.server.PlayerManager.saveAllPlayerData() once per save interval, writing every online player's data to disk in a single tick. On servers with many players or with a lot of player data, this can cause a large MSPT spike.
Incremental Player Save fixes this by spreading player saves across multiple ticks, saving a small batch of players per tick rather than all at once. This mod was inspired by Paper's incremental player saving feature.
Who This Is For
Install this mod if you see any of the following:
- Regular MSPT spikes every auto-save interval (default: every 6000 ticks / 5 minutes)
net.minecraft.server.PlayerManager.saveAllPlayerData appearing in Spark profiler results during spikes
This mod targets only player .dat file writes. It will not reduce spikes from chunk saving or other auto-save work.
Configuration
All options are in the mod's config file in config/incrementalplayersave.json
| Option |
Description |
Default |
ticksBetweenSaveAttempts |
How often (in ticks) the mod checks which players are due for a save |
20 |
ticksBetweenSavesPerPlayer |
Minimum ticks between saves for any individual player |
6000 |
maxPlayersSavedPerAttempt |
Maximum number of players saved per attempt. Controls per-tick save cost |
3 |
enableDebugLog |
Log save actions to console |
false |
Other Notes
-
Some optimization mods may include similar functionality. Use Spark to confirm whether saveAllPlayerData still appears in your profiles before installing. On my server with many optimization mods like Lithium, none of them alleviated the tick spike caused by PlayerManager.saveAllPlayerData().
-
net.minecraft.server.PlayerManager.saveAllPlayerData() is net.minecraft.server.players.PlayerList.saveAll() in Mojang Mappings.
评论 0
登录后参与评分
还没有评论,来抢沙发吧