MaxTPS
事情已经发生——现已开源:
当前的维护者目前没有时间支持该插件,欢迎新的维护者加入!
我们很可能在几个月后回归开发,但没必要扣留人们正在使用(并不断向我们反馈)的代码。
例如,我们将把这个项目交给第一个将其移植到 1.2 版并编写新文档的人(MaxTPS 2 替换了 Minecraft 的多个部分,它还做了一些更激进的事情——比如直接从 .mca 文件向服务器外发送远距离区块!)
最新更新/发布的论坛帖子(此 Wiki 落后于实际进度!):
Max TPS 是一个用于减少大多数大型(50+ 人)Bukkit 服务器卡顿的插件。
虽然与某些插件配合使用时效果最佳,但它不同于大多数旨在提升性能的非官方 Bukkit 分支。
它通过明智地限制 Minecraft 中两个极其消耗性能的因素来维持性能:
- 加载区块的数量。这是通过动态调整视距来实现的。
- 生成的实体数量
通常情况下,在不严重影响游戏玩法的情况下,可以获得约 20% 到 30% 的性能提升;此后你将不得不采取一些不太优雅的手段,例如限制生长率、设置严格的怪物生成上限或将视距降至 5 以下。关于导致服务器卡顿的具体信息可以通过 /lag 命令获取,其输出如下所示:
/lag
05:14:24 [INFO] There are 5739 entities, 152 players, 1405 spawnermobs
05:14:24 [INFO] [############________]/Mem u=6106M f=3792M t=9898M
05:14:24 [INFO] [####################]/Chunks 36722/30000 (122%)
05:14:24 [INFO] [##################__]/1min TPS 18.02 avg, 19.24 abs
05:14:24 [INFO] [###################_]/1sec TPS 19.94 avg, 19.87 abs
05:14:24 [INFO] [##########__________]/VDist 7 = 225 chunks (3 - 15)
注意! 为了与 NoLagg 共存,请在 NoLagg 中禁用怪物生成限制和物品堆叠合并功能!
世界中的区块数量
游戏中的每个玩家都被加载的区块所包围,这在 server.properties 中被称为“视距”(view-distance)。
此设置对服务器性能有巨大影响,先看一些数据:
view-distance=1: 9 chunks
view-distance=2: 25 chunks
view-distance=3: 49 chunks
view-distance=4: 81 chunks
view-distance=5: 121 chunks
view-distance=6: 169 chunks
view-distance=7: 225 chunks
view-distance=8: 289 chunks
view-distance=9: 361 chunks
view-distance=10: 441 chunks
view-distance=11: 529 chunks
view-distance=12: 625 chunks
view-distance=13: 729 chunks
view-distance=14: 841 chunks
view-distance=15: 961 chunks
因此,如果有 50 名玩家在线,且你使用的是视距 15(视距 8 则为 14450),则必须同时加载 50*961=48050 个区块。这当然是最坏的情况,有时人们彼此之间的距离小于视距,从而共享一些区块。
Minecraft 会在每个刻(tick)处理所有已加载的区块。这设定了一个硬性上限,因为当今最先进的 CPU/总线架构似乎最多只能处理每核心 30k 个区块,超过这个数值后 TPS 会迅速下降。
解决方法是根本不要让区块数量达到那么高——只需定义你的服务器能够处理的区块最大数量,并根据该值调整视距。假设你的服务器能够处理 15k 个区块。
config.yml:
max-dist: 15
min-dist: 3
chunk-limit: 15000
up-interval: 30
down-interval: 300
tps-threshold: 18.5
常规检查,在线人数分别为 50、60、100 和 200 时:
- 15000/50 -> 每人 300 个区块,切换至视距 8
- 15000/60 -> 每人 250 个区块,切换至视距 7
- 15000/100 -> 每人 150 个区块,切换至视距 5
- 15000/200 → 每个头部区块 75 个,切换至视距 3
检查是否可以调整视距的操作以可定义的间隔进行,每 30 秒增加一次,每 5 分钟减少一次。
尽量使增加和减少的间隔尽可能拉开距离,以防止振荡。这是因为实际上无法真正施加严格的区块数量上限,有些插件会始终加载它们,而其他一些插件可能会强制卸载部分区块……我们只是在玩猜谜游戏,不过大多数情况下它都能合理运作。
NEW! 由于在服务器上有大量玩家在线之前,区块数量通常没有意义,因此仅当当前 TPS 高于 tps-threshold(TPS 阈值)时才应用视距增加;同样,当当前 TPS 低于该阈值时则减少视距。尽管如此,仍适用所定义的区块数量目标。
确定服务器的极限
- 安装此插件并定期检查 /lag。
- 尝试找到 TPS 开始下降到你不满意水平的临界点,然后执行 /maxchunks 14000 并随后使用不带参数的 /viewdist 命令以立即强制执行更改。
- 不断重复步骤 2,同时降低数值,直到 TPS 恢复到你期望的水平。
除非你真正理解其工作原理及后果,否则请勿使用带参数的 /mindist、/maxdist 和 /viewdist!
限制世界中实体的数量
config.yml:
item-stacking-radius: 3.5
mobs-per-spawner: 30
spawner-check-interval: 30
ticks-per-monster: 1
ticks-per-animal: 400
目前,物品和经验球合并功能正在使用中。另一个导致延迟的来源是玩家在刷怪笼周围建造的 XP 陷阱。每次刷怪笼生成怪物时,它都会被添加到该区块中已生成的生物列表中。如果生物数量超过每个区块的限制,则该处的刷怪笼将不再进一步生成怪物。“自然”生物生成不受此影响。生物会记住它们出生的区块,并且每当它们消失/死亡时,限制将会恢复。
检查刷怪笼是否可以重新启用的操作每隔 spawner-check-interval 执行一次。这是因为 Bukkit 不提供任何关于怪物消失的通知机制,因此我们必须偶尔统计所有情况。
NEW:现在可以修改服务器尝试生成怪物或动物所需的刻数。在某些情况下,将 ticks-per-monster 增加到 10 或更高可以减少服务器延迟(请注意,这可能会影响游戏玩法,因为怪物生成速度会变慢)。
依赖项/冲突
- Orebfuscator 似乎工作正常
- NoLagg 1.70 及更高版本看起来工作正常——但请禁用物品堆叠形成和生成限制(MaxTPS 实现了自己的,据称更好的限制)。
- 此插件使用 Groovy 语言编写,依赖于其运行时环境 —— McGroovy。它已包含在 .zip 文件中,以免让你感到惊讶。
- ChunkManager 似乎工作正常,但请设置 /maxdist 10 以防止不必要的开销(CM 忽略大于 10 的视距)
待办事项
计划用于 Bukkit 1.2 版本发布:
- 完全自定义的智能随机怪物生成可以将生物数量减少到大约原来的 1/3
- 尝试将 Packet51MapChunk 完全移出主线程,从而使区块加载变为异步
游戏指令
- /lag - 显示格式整齐的关键服务器资源视图(tps、内存使用情况、视距、生物数量等)
- /tps - lag 的别名
- /viewdist - 强制立即更改视距
- /maxdist - 设置自动调整的最大视距
- /mindist - 设置自动调整的最小视距
- /upinterval - 尝试将视距增加 1 的时间间隔(直至 maxdist)
- /downinterval - 同上,但用于递减
- /chunklimit - 你的服务器能够处理的区块数量。小型 VPS 为 5-10k,独立服务器为 15-25k,大型服务器为 25-40k
- /mtreload - 从配置文件重新加载
- /stacking - 设置堆叠半径(设为 0 以禁用)
- /spawnerlimit - 限制每个刷怪笼区块的生物数量
- /tpanimal - 动物生成的刻数(默认值为 400 = 每 20 秒生成一只动物)
- /tpmonster - 敌对怪物生成的刻数(默认值为 1 = 每秒生成 20 只怪物)
- /threshold - 设置 MaxTPS 开始影响视距的 TPS 阈值。当当前 TPS 高于此数值时增加视距(最多至 chunklimit),低于此阈值时减少视距
权限节点
所有权限均采用 tps.commandname 格式,例如 tps.lag 应授予所有人,其余权限仅限管理员使用。
MaxTPS
It's happened - NOW OPENSOURCED:
Current maintainers dont have the time to support the plugin atm, NEW MAINTAINERS ARE WELCOME!
It's most likely we'll return back to the development in a few months, but there is no point holding back code people are finding useful (and constantly bugging us about it).
Ie, we will give up this project to the first guy who ports it to 1.2 & writes new docs (MaxTPS 2 replaces several parts of minecraft, it also does some more drastic things - like sending far chunks off-server directly from .mca files!)
Forum thread for latest updates/releases (this wiki lags behind!):
Max TPS is a plugin to reduce server lags on most of larger (50+ man) Bukkit servers.
Although best results are observed in combination with, it works unlike most of the unofficial Bukkit forks aiming at performance.
The performance is maintained by wisely limiting two heavily taxing things in Minecraft:
- number of loaded chunks. This is achieved by dynamically adjusting view-distance.
- number of entities spawned
Most of the time, about 20% to 30% performance gains are observed without affecting gameplay much, after that you'l have
to resort to dirty tricks such as limiting growth rate and hard mob spawn limits or view distance below 5. Detailed info about things lagging your server are obtained via /lag command, it looks like this:
/lag
05:14:24 [INFO] There are 5739 entities, 152 players, 1405 spawnermobs
05:14:24 [INFO] [############________]/Mem u=6106M f=3792M t=9898M
05:14:24 [INFO] [####################]/Chunks 36722/30000 (122%)
05:14:24 [INFO] [##################__]/1min TPS 18.02 avg, 19.24 abs
05:14:24 [INFO] [###################_]/1sec TPS 19.94 avg, 19.87 abs
05:14:24 [INFO] [##########__________]/VDist 7 = 225 chunks (3 - 15)
BEWARE! To coexist with NoLagg disable mob spawn limits and item stack merging in NoLagg!
Number of chunks in the world
Every player in game is surrounded by loaded chunks, this is so called 'view-distance' in server.properties. This
setting affects server performance drastically, first some numbers:
view-distance=1: 9 chunks
view-distance=2: 25 chunks
view-distance=3: 49 chunks
view-distance=4: 81 chunks
view-distance=5: 121 chunks
view-distance=6: 169 chunks
view-distance=7: 225 chunks
view-distance=8: 289 chunks
view-distance=9: 361 chunks
view-distance=10: 441 chunks
view-distance=11: 529 chunks
view-distance=12: 625 chunks
view-distance=13: 729 chunks
view-distance=14: 841 chunks
view-distance=15: 961 chunks
So for 50 people online, there must be 50*961=48050 chunks loaded at the same time if you're using view-distance of 15 (14450 for view-dist 8 etc). This is of course worst-case scenario, sometimes people are closer together than view distance, thus sharing some chunks.
Minecraft processes every chunk loaded, every tick. This imposes hard limit, because best of todays modern CPU/bus architectures seem to be capable of handling 30k chunks per core max, tps goes down the drain quickly after that.
A way around it is to simply never go that high with chunk count - just define maximum number of chunks your server is capable of handling and adjust view distance according to that. So lets assume your server is capable of handling of 15k chunks.
config.yml:
max-dist: 15
min-dist: 3
chunk-limit: 15000
up-interval: 30
down-interval: 300
tps-threshold: 18.5
routine check, 50, 60, 100 and 200 people online:
- 15000/50 -> 300 chunks per head, switch to view distance 8
- 15000/60 -> 250 chunks per head, switch to view distance 7
- 15000/100 -> 150 chunks per head, switch to view distance 5
- 15000/200 -> 75 chunks per head, switch to view distance 3
Checks if view-dist can be adjusted are done in definable interval, increase every 30 seconds, decrease every 5 minutes.
Try to have up and down intervals as far apart as possible, to prevent oscillations. This is because truly hard limits on chunk count cannot be really imposed, some plugins like them always loaded, some other plugin might be unloading some by force .. we're just playing guessing game, however it works reasonably most of the time.
NEW! Because chunk counts are usually meaningless until significant amount of people are online on the server, view-dist increases are applied ONLY if current TPS is above tps-threshold, likewise decreased when current TPS is below tps-threshold. The aim for defined chunk count still applies, though.
Figuring out the limits of your server
- Install this plugin and check /lag routinely.
- Try to find the point when TPS starts going down below your taste and try /maxchunks 14000 followed by /viewdist command without arguments to enforce the change immediately.
- Keep repeating 2. while decreasing the number until TPS is back to where you want it.
Use /mindist, /maxdist and /viewdist with argument only if you truly understand how it works and the implications!
Limiting number of entities in the world
config.yml:
item-stacking-radius: 3.5
mobs-per-spawner: 30
spawner-check-interval: 30
ticks-per-monster: 1
ticks-per-animal: 400
At this moment, item and experience orb merging is used. Another source of lag are XP traps built by players around mob spawners. Every time a spawner creates a monster, it is added to a list of mobs spawned in that chunk. If the mob count exceeds the limit per chunk, no further monsters are spawned by mob spawners in there. "Natural" mob spawn is not affected by this. Mobs remember which chunk they were born in, and the limit will be replenished whenever they despawn/die.
The check if spawner can be re-enabled is performed every spawner-check-interval. This is because bukkit provides NO MEANS of notification when monster despawns, so we have to count em all once in a while.
NEW: It is now possible to modify number of ticks after which server tries to spawn monster or animal. Increasing ticks-per-monster to 10 or more can reduce server lags under some circumstances (note that this may affect gameplay because mobs spawn at lower pace).
Dependencies/clashes
- Orebfuscator seems to work fine
- NoLagg 1.70 and higher appears to work correctly - but disable item stack forming and and spawn limits (MaxTPS implements its own, supposedly better).
- This plugin is written in Groovy language, it depends on its runtime - McGroovy. It's included in the .zip, just so that you're not surprised.
- ChunkManager seems to work fine, but set /maxdist 10 to prevent unnecessary overhead (CM ignores view-distance larger than 10)
TODO
This is planned for 1.2 release of bukkit:
- completely custom, smart random monster spawning can reduce mob count to roughly 1/3
- try to move Packet51MapChunk completely out of main thread, thus making chunk loads asynchronous
Game commands
- /lag - shows neatly formatted view of critical server resources (tps, memory usage, view distance, mob counts...)
- /tps - alias for lag
- /viewdist - force immediate view distance change
- /maxdist - set maximum view distance for auto-adjust
- /mindist - set minimum view distance for auto-adjust
- /upinterval - interval to try to increase viewdist by 1 (up to maxdist)
- /downinterval - ditto, but for decrements
- /chunklimit - number of chunks your server is capable of handling. 5-10k small VPS, 15-25k dedicated, 25-40k big iron
- /mtreload - reload from config file
- /stacking - set stacking radius (0 to disable)
- /spawnerlimit - limit number of mobs per spawner chunk
- /tpanimal - ticks per animal spawns (400 default = spawn animal every 20 seconds)
- /tpmonster - ticks per hostile monster spawns (1 default = spawn 20 mobs every second)
- /threshold - Set TPS threshold for MaxTPS to start affecting view distance. Increases viewdist (up to chunklimit) when current tps is above this number, decreases when current TPS is below this threshold
Permission nodes
All permissions are in the format of tps.commandname, for example tps.lag should be given to everyone, the rest only to administrators.
评论 0
登录后参与评分
还没有评论,来抢沙发吧