StateStream
针对 Minecraft 26.1.2 的激进性能优化——零游戏玩法改动,保证安全。
StateStream 精准定位 Minecraft 服务器循环中三个最昂贵的热点路径,并用轻量、对缓存友好的实现替换它们。每项优化均可独立切换,并在出错时自动禁用,因此配置不当会静默回退到原版行为,而不会引发 Bug。
摘要
StateStream 模组移除了游戏中大量不必要的检查,从而使你的服务器运行更加流畅。如果你的 TPS 未达到 20(20 为最大值),这将有助于提高 TPS。因此,当你遇到服务器卡顿问题时,该模组尤其有用。即使你的 TPS 不低于 20(20 为最大值),该模组仍然会有帮助,因为你的计算机需要进行的计算量减少了。因此,在单人游戏或在计算机上托管服务器/世界时,该模组极其有用,它允许 PC 使用更多的 CPU 资源来提供更高的 FPS。
性能提升
FPS(客户端每秒帧数)
StateStream 的优化位于服务器端,但它通过以下三种方式间接提升客户端 FPS:
1. 减少服务器卡顿尖峰 → 更平滑的动画插值
当服务器错过一个刻(低于 20 TPS)时,客户端会对实体和方块位置进行错误的插值。橡胶带效应、卡顿和“抖动”式移动都源于服务器卡顿。StateStream 使服务器更稳定地保持在 20 TPS,这在客户端体验上表现为可见的更平滑帧率,即使你的实际 GPU FPS 没有变化。
2. 单人游戏 / 集成服务器(对单人玩家最重要)
在单人游戏中,服务器和客户端共享同一个 CPU。服务器刻中节省的每一毫秒都会返还给渲染线程。在一个典型的生存世界中:
- BlockState 缓存在区块渲染边界计算期间消除了冗余的 HashMap 遍历
- 响应式刻减少了在刻线程中花费的时间,直接降低了帧时间
预计单人游戏 FPS 提升:基准 60 FPS 下增加 +3 – 12 FPS;在服务器占用更多 CPU、渲染距离较高、以及从同一台 PC 托管多人世界时增益更高。
3. 减少垃圾回收压力
扁平的 long[] 缓存避免了原版通用属性系统在每个刻中产生的数千个装箱 Boolean 和 Integer 对象分配。更少的短生命周期对象 → 更少的 GC 停顿 → 更少的掉帧。
注意!
只有当服务器/世界与客户端在同一台计算机上运行时,才能看到 FPS 的提升,例如在你的 PC 上本地为你的朋友和你自己托管服务器,或使用 Essentials 等插件。当模组安装在外部运行的服务器上时,你会体验到服务器运行更流畅,而不是你的客户端。
各项优化工作原理
JIT BlockState 内联
Minecraft 中的每个方块都有一个或多个 BlockState(草方块有 snowy: true/false,原木有 axis: x/y/z 等)。原版通过 StateHolder 内部的通用 HashMap 查找属性——灵活,但在每刻调用数百万次时速度较慢。
StateStream 在启动时将五个最常查询的属性(solid、opaque、hasCollision、isAir、lightEmission)预烘焙到一个扁平的 long[] 数组中,每个方块状态 ID 对应一项。查找变为单次数组读取,而非地图遍历。数组布局使得经常共同访问的属性共享相同的 CPU 缓存行。
响应式方块刻
原版在每个子区块每刻采样 random.nextInt(4096)。在一个典型的生存世界中,这 4096 个位置中的大多数是空气或不可刻的石块。StateStream 维护了一个仅包含可刻方块位置(作物、草、海带、冰等)的注册表,并直接跳转到这些位置。
刻率与原版在数学上完全相同。 每个刻每个方块的 1/4096 概率被精确保留——我们不会切换到轮询或确定性调度。作物生长速率、冰形成、树木蔓延——所有统计结果相同,只是更平滑且占用更少的 CPU。
更新剔除
当一个方块发生变化时,Minecraft 最多通知 6 个相邻方块。其中许多通知确实是必要的(红石、水流、落沙)。但有些接收方块可能不会对通知做任何处理——它们接收通知后立即返回。
StateStream 允许你在 JSON 配置文件中注册这些“惰性对”。在传播邻居通知之前,它会检查表格,如果接收方已知对该源是惰性的,则跳过调用。默认配置为空——开箱即用零抑制,最大安全性。
命令
需要操作员等级 2。
/statestream stats — 缓存命中率、抑制的更新、追踪的可刻位置
/statestream status — 哪些模块处于活动状态 / 已自禁用
/statestream reload — 重新加载 inert_pairs.json 无需重启
/statestream benchmark — 计时性能扫描(结果记录在服务器日志中)
配置
config/statestream.toml — 首次启动时以安全默认值自动创建:
[general]
jit_inlining_enabled = true
update_culling_enabled = true
reactive_ticking_enabled = true
debug_logging = false
[culling]
inert_pairs_file = "config/statestream/inert_pairs.json"
所有三个模块均可独立切换。在任何配置行中禁用与另一个模组冲突的任何模块。
常见问题 - 只是我在回答自己的问题 - 嘿 :(
这会改变我的农场的运作方式吗?
不会。刻率、生长概率和所有随机刻行为在数学上与原版完全相同。1/4096 概率模型被精确保留。
这会破坏红石吗?
默认情况下不会。更新剔除附带零抑制对。除非你手动添加惰性对(并且仅在根据原版源代码验证后),否则红石行为完全不受影响。
这可能会损坏我的存档吗?
不会。StateStream 永远不会写入区块数据或修改世界状态。它仅改变服务器读取方块属性的速度,而不改变这些属性本身的内容。
如果出现问题会怎样?
受影响的模块会记录警告并静默禁用自身。在会话的其余部分,你的世界将继续按照原版行为运行。不会崩溃,也不会丢失数据。
StateStream
Radical performance optimization for Minecraft 26.1.2 — zero gameplay changes, guaranteed.
StateStream surgically targets three of the most expensive hot-paths in Minecraft's server loop and replaces them with lean, cache-friendly implementations. Every optimization is independently toggleable and self-disabling on error, so a bad config silently falls back to vanilla rather than causing bugs.
Summary
The Statestream mod removes a lot of unnececary cheks in the game which allows your server to run more smothly. This makes your TPS higher if it issnt at 20 (20 is max). So the mod is especially helpfull if you experience server lag. Even though you dont have less that 20 TPS (20 is max) the mod will still help because your computer has to do fewer calculation. Therefore the mod is extremely helpfull when playing singleplayer or hosting a server/world on your computer as it allows the PC to use more of the CPU to give you higher FPS.
Performance Improvements
FPS (Client Frames Per Second)
StateStream's optimizations live on the server side, but they indirectly improve client FPS in three ways:
1. Fewer server lag spikes → smoother animation interpolation
When the server misses a tick (falls below 20 TPS), the client interpolates entity and block positions incorrectly. Rubber-banding, stuttering, and "jittery" movement all trace back to server lag. StateStream keeps the server at 20 TPS more consistently, which the client experiences as a visibly smoother framerate even if your actual GPU FPS hasn't changed.
2. Singleplayer / integrated server (most important for solo players)
In singleplayer, the server and client share the same CPU. Every millisecond saved in the server tick is a millisecond returned to the render thread. In a typical survival world:
- BlockState cache eliminates redundant HashMap traversals during chunk rendering border calculations
- Reactive ticking reduces time spent in the tick thread, directly lowering frame times
Estimated singleplayer FPS improvement: +3 – 12 FPS at 60 FPS baseline; higher gains where the server is using more of the CPU, higher render distance, multiplayerworlds hosted from same PC as client.
3. Reduced garbage collection pressure
The flat long[] cache avoids thousands of boxed Boolean and Integer object allocations per tick that vanilla's generic property system produces. Fewer short-lived objects → fewer GC pauses → fewer frame drops.
**NB!
FPS improvments will only be seen when the server/world is running on the same computer as the client, for example when hosting a server for you and your friends localy on your PC or using essentials etc. When the mod is put on a server running externaly you will experience that the server is running smoother rather than your client.
How Each Optimization Works
JIT BlockState Inlining
Every block in Minecraft has one or more BlockStates (a grass block has snowy: true/false, a log has axis: x/y/z, etc.). Vanilla looks up properties through a generic HashMap inside StateHolder — flexible, but slow when called millions of times per tick.
StateStream pre-bakes the five most-queried properties (solid, opaque, hasCollision, isAir, lightEmission) into a flat long[] array at startup, one entry per blockstate ID. A lookup becomes a single array read instead of a map walk. The array is laid out so frequently co-accessed properties share the same CPU cache line.
Reactive Block Ticking
Vanilla samples random.nextInt(4096) per subchunk per tick. In a typical survival world, most of those 4096 positions are air or non-tickable stone. StateStream maintains a registry of only the positions that contain tickable blocks (crops, grass, kelp, ice, etc.) and skips straight to them.
Tick rates are mathematically identical to vanilla. The 1/4096 probability per block per tick is preserved exactly — we don't switch to a round-robin or deterministic schedule. Crop growth rates, ice formation, tree spread — everything is statistically the same, just smoother and using less of the CPU.
Update Culling
When a block changes, Minecraft notifies up to 6 neighboring blocks. Many of those notifications are genuinely necessary (redstone, water flow, falling sand). But some receiver blocks probably do nothing with the notification — they receive it and immediately return.
StateStream lets you register these "inert pairs" in a JSON config file. Before propagating a neighbor notification, it checks the table and skips the call if the receiver is known-inert for that source. The default config ships empty — zero suppression out of the box, maximum safety.
Commands
Requires operator level 2.
/statestream stats — cache hit rate, suppressed updates, tracked tickable positions
/statestream status — which modules are active / self-disabled
/statestream reload — reload inert_pairs.json without restarting
/statestream benchmark — timed performance scan (results in server log)
Configuration
config/statestream.toml — auto-created with safe defaults on first launch:
[general]
jit_inlining_enabled = true
update_culling_enabled = true
reactive_ticking_enabled = true
debug_logging = false
[culling]
inert_pairs_file = "config/statestream/inert_pairs.json"
All three modules are independently toggleable. Disable any module that conflicts with another mod in a single config line.
FAQ - just that im answering my own questions - heh :(
Will this change how my farms work?
No. Tick rates, growth probabilities, and all random-tick behaviour are mathematically identical to vanilla. The 1/4096 probability model is preserved exactly.
Will this break redstone?
Not by default. Update Culling ships with zero suppressed pairs. Redstone behavior is entirely unaffected unless you manually add inert pairs (and only after verifying them against vanilla source).
Can this corrupt my world?
No. StateStream never writes block data or modifies world state. It only changes how fast the server reads block properties, not what those properties are.
What happens if something goes wrong?
The affected module logs a warning and silently disables itself. Your world continues on vanilla behavior for the rest of that session. No crash, no data loss.
评论 0
登录后参与评分
还没有评论,来抢沙发吧