Sepals
一款极具激进性和实验性的 Minecraft 服务器性能优化模组。
我们建议将 Sepals 与 Lithium 和 Async 配合使用,以获得最佳性能。
前言
首先,
Sepals 是一组高度实验性的服务端优化方案,旨在解决 Minecraft AI、实体处理及任务系统中非常特定的性能瓶颈。与 Lithium 提供广泛的“通用”优化不同,Sepals 专注于对少数极其昂贵的原版机制进行深度重写——特别是村民大脑(villager brains)、青蛙行为、实体挤压(entity cramming)、目标过滤以及附近实体感知。
那么它在实践中具体做了什么?
如果你运行着大型农场、村民大厅、密集的怪物围栏,
或者任何在有限区域内拥有数百/数千实体的场景,
Sepals 通过避免原版最昂贵的 AI 操作,大幅降低了刻时间(tick time)。
如果你运行的是拥有小型农场的普通多人游戏(SMP),你可能不会注意到太大差异。
它是实验性的,并非所有优化都能保证与原版的完全一致,
但在性能压力测试中,提升可能非常巨大。
兼容性
重要提示
Sepals 不支持任何旧版本或快照版本的 Minecraft;所有 bug 修复和功能仅在新版本中可用。
当与 Async 一起使用时,
请手动对比 Sepals 和 Async 的性能,并编辑它们的配置文件,以找出哪些优化是 worthwhile(值得开启的),
因为每台机器的结果会有所不同。
Sepals 相关功能:enableSepalsEntitiesCramming。
配置
| 配置名称 |
允许的值 |
默认值 |
| forceEnableSepalsPoi |
布尔值 |
false |
| enableSepalsVillager |
布尔值 |
true |
| enableSepalsFrogLookAt |
布尔值 |
true |
| enableSepalsFrogAttackableSensor |
布尔值 |
true |
| enableSepalsLivingTargetCache |
布尔值 |
true |
| nearestLivingEntitiesSensorUseQuickSort |
布尔值 |
true |
| enableSepalsBiasedLongJumpTask |
布尔值 |
true |
| enableSepalsEntitiesCramming |
布尔值 |
true |
| enableSepalsItemMerge |
布尔值 |
true |
| enableSepalsQuickCanBePushByEntityPredicate |
布尔值 |
true |
性能
在 feimia 提供的 Mars 服务器上进行了测试,CPU:Intel i7-14700K;游戏内存:4G;操作系统:Ubuntu 24.04.1 LTS;
Minecraft:1.21。
实体挤压
使用盒子缓存来防止过多的 'getOtherEntities' 调用
-- 注意 --
此功能忽略每个实体的记分板/队伍谓词
可能会导致意外行为。
这个问题不会影响原版中的任何东西,除非在使用命令方块时。
-- 状态 --
默认启用
在 7x7 的空间内拥挤了 1390 个村民:
| 环境 |
tickCramming |
百分比 (平均) |
| 原版 |
53.6 ms |
100 % |
| Lithium |
54.4 ms |
101 % |
| Sepals |
10.2 ms |
19 % |
| Sepals + Lithium |
8.5 ms |
15 % |
加权随机
使用二分搜索替换原版的加权随机
-- 警告 --
此功能可能不值得,
因为 Spark 证明在构建范围表时它比原版慢,
即使二分搜索接近 0 ms。
-- 状态 --
默认禁用
-- 警告 --
未测试。
偏向长跳任务
使用 Sepals 的长跳任务实现替换原版
如上所述,二分搜索几乎没有开销
sepals 实现将在生成目标的同时构建范围表
并使用 Catheter 替换 java stream
同时,重新排列青蛙大脑中的跳跃条件,从而获得良好的性能
-- 注意 --
此功能无法在游戏运行时更改
需要重启服务器以应用更改
-- 状态 --
默认启用
在 7x7 的空间内拥挤了 800 只青蛙:
| 环境 |
keepRunning |
百分比(平均) |
原版 (LongJumpTask) |
43.1 ms |
100 % |
Lithium (LongJumpTask) |
7.5 ms |
17 % |
Sepals (SepalsLongJumpTask) |
0.2 ms |
0.4 % |
Sepals + Lithium (SepalsLongJumpTask) |
0.05 ms |
0.1 % |
| 环境 |
getTarget |
百分比(平均) |
百分比(in keepRunning) |
原版 (LongJumpTask) |
43.1 ms |
100 % |
100 % |
Lithium (LongJumpTask) |
3.6 ms |
9 % |
48 % |
Sepals (SepalsLongJumpTask) |
N/A ms |
0 % |
0 % |
Sepals + Lithium (SepalsLongJumpTask) |
N/A ms |
0 % |
0 % |
NearestLivingEntitiesSensor 中的快速排序
使用 FastUtil 的快速排序替换 Java TIM 的排序
-- 状态 --
默认启用
在 7x7 的空间内拥挤了 800 只青蛙:
| 环境 |
sort (NearestLivingEntitiesSensor#sense) |
百分比(平均) |
| 原版 |
3.8 ms |
100 % |
| Lithium |
3.6 ms |
94 % |
| Sepals |
2.2 ms |
57 % |
| Sepals + Lithium |
2.2 ms |
57 % |
青蛙可攻击目标过滤器
重新排列可攻击条件,
将成本最低的条件放在最前面,
从而降低高成本计算的概率
-- 问题所在 --
Mojang 的可攻击谓词如下:
!entity.getBrain().hasMemoryModule(MemoryModuleType.HAS_HUNTING_COOLDOWN)
&& Sensor.testAttackableTargetPredicate(entity, target)
&& FrogEntity.isValidFrogFood(target)
&& !this.isTargetUnreachable(entity, target)
&& target.isInRange(entity, 10.0)
在这种情况下,'Sensor#testAttackableTargetPredicate' 会调用 'TargetPredicate#test',
当区域内实体过多时,这会导致大量的射线投射计算,
考虑到 Minecraft 的射线投射计算极其缓慢,情况甚至会更糟。
在此情况下,'TargetPredicate#test'(800 只青蛙)每个游戏刻消耗了 9.8ms,
而 'BlockView.raycast' 贡献了 7.3ms。
因此,我将其更改为:
FrogEntity.isValidFrogFood(target) &&
entity.getBrain().hasMemoryModule(MemoryModuleType.HAS_HUNTING_COOLDOWN) &&
target.isInRange(entity, 10.0) &&
Sensor.testAttackableTargetPredicate(entity, target) &&
isTargetUnreachable(entity, target);
'isValidFrogFood' 是一个简单的条件,它检查实体的 'frog_food' 标签,
并在实体是史莱姆时进行额外检查,如果大小不为 1 则跳过。
'isInRange' 和 'hasMemoryModule' 也很好,因为它们只计算一些简单的事物。
-- 状态 --
默认启用
800 只青蛙挤在 7x7 的空间内:
| 环境 |
时间 |
百分比(平均) |
| 原版 (FrogAttackablesSensor#matches) |
10 ms |
100 % |
| Lithium (FrogAttackablesSensor#matches) |
5.7 ms |
57 % |
| Sepals (SepalsFrogBrain#attackable) |
0.1 ms |
1 % |
| Sepals + Lithium (SepalsFrogBrain#attackable) |
0.1 ms |
1 % |
青蛙注视目标过滤器
使用 'SepalsLivingTargetCache' 来改善目标搜索性能
您必须启用该选项,否则此功能与原版相同
-- 注意 --
射线投射位于 TargetPredicate 测试中,
在 LivingTargetCache 的 'findFirst' 处,当输入谓词成功时执行。
但如果后续条件失败,继续计算这部分就毫无意义了,
因为即使 findFirst 找到了目标(射线投射成功),
但在后续上下文中我们并未使用这个结果。
-- 状态 --
默认启用
800 只青蛙挤在 7x7 的空间内:
| 环境 |
findFirst |
百分比 |
原版 (LookAtMobWithIntervalTask$$Lambda#findFirst) |
2.7 ms |
100 % |
Lithium (LookAtMobWithIntervalTask$$Lambda#findFirst) |
2.5 ms |
92 % |
Sepals (SepalsLookAtMobWithIntervalTask$$Lambda#findFirstPlayer) |
0.1 ms |
3 % |
Sepals + Lithium (SepalsLookAtMobWithIntervalTask$$Lambda#findFirstPlayer) |
0.1 ms |
3 % |
村民杂项优化
这是 Sepals 所做的操作:
1. 使用 Catheter 替换 Java 的 Stream,因为它相比 Stream 具有更好的性能和可扩展性
2. 缓存任务、活动、运行中的任务和记忆,以改善启动和更新任务的时间
3. 使用 sepals 复合任务替换原版复合任务
4. 尽可能寻找机会跳过更多的射线投射和无用的谓词
5. 使用 'SepalsLivingTargetCache' 替换原版缓存,代价是在传感器刻中减少开销,从而在寻找交互目标或注视生物任务中节省成本
6. 重新排列谓词并添加额外的低开销谓词,目的是推迟高开销谓词的判断或尽量避免执行,提前跳过剩余的高开销谓词
7. 复制并修改来自 Lithium 的 'SerializingRegionBasedStorage' 优化
8. 针对更多特定任务,不使用泛型以减少无用操作
9. 使用二分查找列表替换 HashSet 搜索
-- 注意 --
建议将此与 Lithium 和 C2ME 配合使用以获得最佳性能
-- 警告 --
未经长期稳定性测试,仅一个月的运行显示目前正常。
该功能尚未被证明与原版完全一致,
但也未出现统计上的显著差异。
-- 状态 --
默认启用
中午时分,800 名村民挤在 7x7 的空间内:
| 环境 |
Brain#tick(总计) |
百分比 |
Brain#startTasks |
百分比(startTasks) |
Brain#tickSensors |
百分比(tickSensors) |
Brain#updateTasks |
百分比(updateTasks) |
Brain#tickMemories |
百分比(tickMemories) |
| Vanilla |
18 ms |
100 % |
9.3 ms |
100 % |
5.2 ms |
100 % |
3 ms |
100 % |
0.5 ms |
100 % |
| Lithium |
12.4 ms |
68 % |
4.8 ms |
51 % |
5.9 ms |
113 % |
1.2 ms |
40 % |
0.5 ms |
100 % |
| Sepals |
9.7 ms |
53 % |
3.6 ms |
38 % |
3.7 ms |
71 % |
2 ms |
66 % |
0.4 ms |
80 % |
| Sepals + Lithium |
10 ms |
55 % |
3.4 ms |
36 % |
3.7 ms |
71 % |
2.5 ms |
83 % |
0.4 ms |
80 % |
夜晚时,800 名村民挤在 7x7 的空间内:
| 环境 |
Brain#tick(总计) |
百分比 |
Brain#startTasks |
百分比(startTasks) |
Brain#tickSensors |
百分比(tickSensors) |
Brain#updateTasks |
百分比(updateTasks) |
Brain#tickMemories |
百分比(tickMemories) |
| Vanilla |
16.7 ms |
100 % |
8.2 ms |
100 % |
6 ms |
100 % |
2 ms |
100 % |
0.5 ms |
100 % |
| Lithium |
10.2 ms |
61 % |
3.2 ms |
24 % |
6 ms |
113 % |
0.5 ms |
25 % |
0.5 ms |
100 % |
| Sepals |
9 ms |
53 % |
3.3 ms |
16 % |
4.7 ms |
78 % |
0.7 ms |
35 % |
0.3 ms |
60 % |
| Sepals + lithium |
8.7 ms |
52 % |
2.9 ms |
11 % |
4.6 ms |
76 % |
0.7 ms |
35 % |
0.5 ms |
100 % |
谓词优化
1172 只青蛙挤在 3x3 的空间内:
| 环境 |
时间 |
平均百分比(Avg.) |
| Vanilla (java.util.function.Predicate.lambda$and$0()) |
49.01 ms |
100 % |
| Sepals (com.github.cao.awa.sepals.entity.predicate.SepalsEntityPredicates$$Lambda/0x000002d8f116e000.test()) |
22.6 ms |
46 % |
Sepals
An extremely radical and experimental optimization mod for Minecraft server performances.
We recommend using Sepals with Lithium and Async for optimal performance.
Foreword
First,
the Sepals is a collection of highly experimental server-side optimizations that target very specific performance bottlenecks in Minecraft’s AI, entity processing, and task systems. Instead of providing broad “general” optimizations like Lithium, Sepals focuses on deep rewrites of a few extremely expensive vanilla mechanisms — especially villager brains, frog behavior, entity cramming, target filtering, and nearby-entity sensing.
So what does it do in practice?
If you run large farms, villager halls, dense mob enclosures,
or any scenario with hundreds/thousands of entities in a small area,
Sepals drastically lowers tick time by avoiding Vanilla’s most expensive AI operations.
If you’re running a normal SMP with small farms, you probably won’t notice much of a difference.
It is experimental, and not every optimization is guaranteed to have Vanilla parity,
but in performance-stress tests, the gains can be huge.
Compatibility
Important
Sepals won't support any old versions and snapshot versions of Minecraft; all bug fixes and features are only available in the newest version.
When using it with Async,
please manually compare performance with Sepals and Async, and edit their configurations, to find which optimizations are worthwhile,
as each machine has different results.
Sepals feature related: enableSepalsEntitiesCramming.
Config
| Config name |
Allowed value |
Default value |
| forceEnableSepalsPoi |
bool value |
false |
| enableSepalsVillager |
bool value |
true |
| enableSepalsFrogLookAt |
bool value |
true |
| enableSepalsFrogAttackableSensor |
bool value |
true |
| enableSepalsLivingTargetCache |
bool value |
true |
| nearestLivingEntitiesSensorUseQuickSort |
bool value |
true |
| enableSepalsBiasedLongJumpTask |
bool value |
true |
| enableSepalsEntitiesCramming |
bool value |
true |
| enableSepalsItemMerge |
bool value |
true |
| enableSepalsQuickCanBePushByEntityPredicate |
bool value |
true |
Performance
A test was done in server of Mars provided by feimia, CPU: Intel i7-14700K; Game memory: 4G; OS: Ubuntu 24.04.1 LTS;
Minecraft: 1.21.
Entities cramming
Use box cache to prevent too much 'getOtherEntities' calls
-- Notice --
This feature ignores scoreboard/team predicates for every single entity
and may cause unexpected behavior.
This problem will not affect anything in Vanilla, except when using
command blocks.
-- Status --
Enabled by default
1390 villagers cramming in a 7x7 space:
| Environment |
tickCramming |
Percent (Avg.) |
| Vanilla |
53.6 ms |
100 % |
| Lithium |
54.4 ms |
101 % |
| Sepals |
10.2 ms |
19 % |
| Sepals + Lithium |
8.5 ms |
15 % |
Weighted random
Use binary search to replace vanilla weight random
-- Warning --
This feature may not be worthwhile,
as Spark proved that it is slower than Vanilla when constructing range tables,
even if the binary search is close to 0 ms.
-- Status --
Disabled by default
-- Warning --
Not tested.
Biased long jump task
Use Sepals long jump task implementation to replace Vanilla
As mentioned above, the binary search is almost no costs
sepals impletation will construct the range table at the same time as generating targets
and used Catheter to replaced java stream
The same time, rearrange should jump conditions in frog brain, make a good performance
-- Notice --
This feature is unable to change in game runtime
required restart the server to apply changes
-- Status --
Enabled by default
800 frogs cramming in a 7x7 space:
| Environment |
keepRunning |
Percent(Avg.) |
Vanilla (LongJumpTask) |
43.1 ms |
100 % |
Lithium (LongJumpTask) |
7.5 ms |
17 % |
Sepals (SepalsLongJumpTask) |
0.2 ms |
0.4 % |
Sepals + Lithium (SepalsLongJumpTask) |
0.05 ms |
0.1 % |
| Environment |
getTarget |
Percent(Avg.) |
Percent(in keepRunning) |
Vanilla (LongJumpTask) |
43.1 ms |
100 % |
100 % |
Lithium (LongJumpTask) |
3.6 ms |
9 % |
48 % |
Sepals (SepalsLongJumpTask) |
N/A ms |
0 % |
0 % |
Sepals + Lithium (SepalsLongJumpTask) |
N/A ms |
0 % |
0 % |
Quick sort in NearestLivingEntitiesSensor
Use quick sorting from FastUtil to replace Java TIM's sorting
-- Status --
Enabled by default
800 frogs cramming in a 7x7 space:
| Environment |
sort (NearestLivingEntitiesSensor#sense) |
Percent(Avg.) |
| Vanilla |
3.8 ms |
100 % |
| Lithium |
3.6 ms |
94 % |
| Sepals |
2.2 ms |
57 % |
| Sepals + Lithium |
2.2 ms |
57 % |
Frog attackable target filter
Rearrange the attackable conditions
to have the least costly conditions first,
and therefore reduce the probability of high-costs calculating
-- The complaints --
Mojang's attackable predicate is:
!entity.getBrain().hasMemoryModule(MemoryModuleType.HAS_HUNTING_COOLDOWN)
&& Sensor.testAttackableTargetPredicate(entity, target)
&& FrogEntity.isValidFrogFood(target)
&& !this.isTargetUnreachable(entity, target)
&& target.isInRange(entity, 10.0)
in this case, 'Sensor#testAttackableTargetPredicate' calls 'TargetPredicate#test'
which causes lots of raycast calculating when there are too many entities in an area,
making it even worse, considering Minecraft's raycast is painfully slow
in this case, 'TargetPredicate#test' (800 frogs) costed 9.8ms per game tick,
and 'BlockView.raycast' contributed 7.3ms
therefore, I changed it to:
FrogEntity.isValidFrogFood(target) &&
entity.getBrain().hasMemoryModule(MemoryModuleType.HAS_HUNTING_COOLDOWN) &&
target.isInRange(entity, 10.0) &&
Sensor.testAttackableTargetPredicate(entity, target) &&
isTargetUnreachable(entity, target);
the 'isValidFrogFood' is a simple condition, it checks the entity's 'frog_food' tag
and an extra check when entity is slime then skip it when it size not 1
'isInRange' and 'hasMemoryModule' are also fine, as they only calculate some simple things
-- Status --
Enabled by default
800 frogs cramming in a 7x7 space:
| Environment |
time |
Percent(Avg.) |
| Vanilla (FrogAttackablesSensor#matches) |
10 ms |
100 % |
| Lithium (FrogAttackablesSensor#matches) |
5.7 ms |
57 % |
| Sepals (SepalsFrogBrain#attackable) |
0.1 ms |
1 % |
| Sepals + Lithium (SepalsFrogBrain#attackable) |
0.1 ms |
1 % |
Frog look-at target filter
Use 'SepalsLivingTargetCache' to improves target search performance
You must have that option enabled, otherwise this is identical to Vanilla
-- Notice --
The raycast is in TargetPredicate test
at the 'findFirst' in LivingTargetCache when input predicate is success
but if subsequent conditions are failures, it is useless to calculate this further
because even if the findFirst has found (raycast success)
but we don't used this result in subsequent contexts
-- Status --
Enabled by default
800 frogs cramming in a 7x7 space:
| Environment |
findFirst |
Percent |
Vanilla (LookAtMobWithIntervalTask$$Lambda#findFirst) |
2.7 ms |
100 % |
Lithium (LookAtMobWithIntervalTask$$Lambda#findFirst) |
2.5 ms |
92 % |
Sepals (SepalsLookAtMobWithIntervalTask$$Lambda#findFirstPlayer) |
0.1 ms |
3 % |
Sepals + Lithium (SepalsLookAtMobWithIntervalTask$$Lambda#findFirstPlayer) |
0.1 ms |
3 % |
Villager miscellaneous optimizations
This is what Sepals does:
1. Use Catheter to replaced Java's Stream, since it has much better performance and scalability compared to Stream
2. Cache tasks, activities, running tasks and memory to improve starting and updating task times
3. Use sepals composite task to replaced vanilla composite task
4. Whenever possible, find opportunities to skip more raycasts and useless predicates
5. Use 'SepalsLivingTargetCache' to replaced vanilla cache, At the cost in sensors tick make less cost in finding interaction target or look at mob task
6. Rearranged predicates and extra lower cost predicate, The purpose of this is do higher cost predicate later or best don't do that, skip the remaining high cost predicates in advance
7. Copied and modified 'SerializingRegionBasedStorage' optimizations from lithium
8. With more targeted task, don't use the generics to reduce useless operations
9. Use binary search list to replace hashset search
-- Notice --
It is recommended to use this with Lithium and C2ME for optimal performance
-- Warning --
Not long-term stability tested, only a month running shown it's ok currently
this feature has not been proved to be identical to Vanilla,
but also hasn't appeared to be statistically different
-- Status --
Enabled by default
800 villagers cramming in a 7x7 space at noon:
| Environment |
Brain#tick (Total) |
Percent |
Brain#startTasks |
Percent(startTasks) |
Brain#tickSensors |
Percent(tickSensors) |
Brain#updateTasks |
Percent(updateTasks) |
Brain#tickMemories |
Percent(tickMemories) |
| Vanilla |
18 ms |
100 % |
9.3 ms |
100 % |
5.2 ms |
100 % |
3 ms |
100 % |
0.5 ms |
100 % |
| Lithium |
12.4 ms |
68 % |
4.8 ms |
51 % |
5.9 ms |
113 % |
1.2 ms |
40 % |
0.5 ms |
100 % |
| Sepals |
9.7 ms |
53 % |
3.6 ms |
38 % |
3.7 ms |
71 % |
2 ms |
66 % |
0.4 ms |
80 % |
| Sepals + Lithium |
10 ms |
55 % |
3.4 ms |
36 % |
3.7 ms |
71 % |
2.5 ms |
83 % |
0.4 ms |
80 % |
800 villagers cramming in a 7x7 space at night:
| Environment |
Brain#tick (Total) |
Percent |
Brain#startTasks |
Percent(startTasks) |
Brain#tickSensors |
Percent(tickSensors) |
Brain#updateTasks |
Percent(updateTasks) |
Brain#tickMemories |
Percent(tickMemories) |
| Vanilla |
16.7 ms |
100 % |
8.2 ms |
100 % |
6 ms |
100 % |
2 ms |
100 % |
0.5 ms |
100 % |
| Lithium |
10.2 ms |
61 % |
3.2 ms |
24 % |
6 ms |
113 % |
0.5 ms |
25 % |
0.5 ms |
100 % |
| Sepals |
9 ms |
53 % |
3.3 ms |
16 % |
4.7 ms |
78 % |
0.7 ms |
35 % |
0.3 ms |
60 % |
| Sepals + lithium |
8.7 ms |
52 % |
2.9 ms |
11 % |
4.6 ms |
76 % |
0.7 ms |
35 % |
0.5 ms |
100 % |
Predicate optimization
1172 frogs cramming in a 3x3 space:
| Environment |
time |
Percent(Avg.) |
| Vanilla (java.util.function.Predicate.lambda$and$0()) |
49.01 ms |
100 % |
| Sepals (com.github.cao.awa.sepals.entity.predicate.SepalsEntityPredicates$$Lambda/0x000002d8f116e000.test()) |
22.6 ms |
46 % |
评论 0
登录后参与评分
还没有评论,来抢沙发吧