Sable:优化实体
一款针对 Sable 的小型优化补丁模组,用于在子层级(Sublevels)中更快地追踪实体。它可以安装在服务器上,这意味着玩家无需更新他们的整合包并添加相同的模组。
注意:尽管在我的测试中它基本上没有 bug,但此模组并不能保证完全稳定。
它是如何工作的?
Sable 原本拥有这段 代码,它通过追踪实体并在特定子层级内发送 Sable 转换后的实体位置,让玩家能够正确看到子层级内的实体。
但问题在于,他们的代码仍然会对所有不在任何子层级内的已加载实体进行无用计算/检查。
例如,在一个大型 Minecraft 服务器中,有 20 名玩家和 1000 个已加载实体,且它们彼此相邻且都不在子层级内。如果我们进行数学计算 20 名玩家 x 1000 个实体,Sable 的检查代码每刻(tick)将运行约 20,000 次。随着更多玩家和实体处于活动状态,性能消耗会急剧增加,从而恶化游戏性能。
因此,我制作了这款极其特定且简单的模组,用更优化的代码替换了 Sable 的追踪代码。(实际上只是一个简单的短路守卫子句,只是为了让它更快 lol)
如果你有以下情况,请使用此模组:
- 大量未处于任何子层级内的活跃实体(如生物和掉落物)
- 许多(如 20 人或更多)活跃玩家
- 大量区块(约 5000 个)被加载
- 根据 Spark 配置文件显示,
ChunkMap.move() 或 sable$trackSubLevelEntities() 特别占用你的 TPS
- 低配服务器
如果以上情况均不适用,那么此模组对你来说不会有效果。
基准测试
测试来源自 Aeronautics 服务器 (STARSOUL),拥有约 25 名真实玩家、约 5100 个区块和约 3500 个活跃实体,CPU 为 AMD EPYC 4564P,分配内存为 12GB。
无模组时

有模组时

这意味着此模组的实体追踪速度比 Sable 快约 3.7 倍。不是很棒吗?
Sable: Optimized Entities
A small optimization patch mod for Sable, for faster entity tracking in Sublevels. It can be installed in the server, meaning no requirement for players to update their modpacks and add the same mod as well.
NOTE: This mod does not guarantee full stability, even though it is mostly free of bugs in my testing.
How does it work?
Sable had this code, that let players see entities within a Sublevel properly by tracking entities and sending Sable's converted entity positions inside of specific Sublevels to the players.
But something is wrong, their code still does useless calculation/checking for ALL loaded entities that aren't inside of any sublevel.
For example in a big Minecraft server, there are 20 players and 1000 entities loaded where all of them are near to each other and not inside of the sublevel. If we do the math where 20 Players x 1000 entities, Sable's checking code runs around 20,000 TIMES per tick. Which it scales really high as more players and entities are active and worsening the performance.
So I've made this ultra-specific and simple mod that replaces Sable's tracking code with an more optimized one. (literally just a simple short circuit guard clause to make it faster lol)
Use this mod if you have:
- Tons of active entities that aren't inside of any sublevel (such as mobs and items)
- Many (such as 20 or more) active players.
- A lot of chunks (around 5000) are loaded
ChunkMap.move() or sable$trackSubLevelEntities() specifically eating your TPS according to Spark profiles.
- A low-end server
If none of these are applicable, then this mod will not be effective for you.
Benchmark
Tested from an Aeronautics server (STARSOUL) with ~25 real players, ~5100 chunks, and ~3500 active entities with an AMD EPYC 4564P CPU and 12GB allocated.
Without Mod

With Mod

Meaning this mod can do ~3.7x faster entity tracking than Sable does. Ain't that neat?
评论 0
登录后参与评分
还没有评论,来抢沙发吧