LazyDFU 是一款针对 Minecraft 的优化模组,它通过推迟不必要的初始化工作,确保仅在需要时才执行这些操作。具体而言,它使 DataFixerUpper 的初始化变得“惰性”——即直到真正需要时,才会创建用于将数据从旧版 Minecraft 迁移到新版所需的规则。
本模组适用于 Fabric/Quilt
兼容性
LazyDFU 0.1.2 兼容 Minecraft 1.14 至 1.18.2,并可在客户端和服务器端运行。
LazyDFU 0.1.3 兼容 Minecraft 1.19 及以上版本,然而 Mojang 现在已在服务器端实现了 LazyDFU 所提供的功能。客户端默认仍会初始化所有 DFU 规则,因此 LazyDFU 会挂钩原生的客户端功能以启用 DFU 规则的烘焙,并将其变为空操作(no-op)。
不过,自 Minecraft 1.19.4 起,Mojang 已对 DFU 初始化进行了大幅优化,使得在许多配置下不再需要此模组。但对于较旧的 Minecraft 版本,我们仍将继续提供支持。
赞助我!
这款模组是否让你能够流畅地游玩 Minecraft?请捐助一点资金,以便我能继续开发它。
为什么它能起作用?
DataFixerUpper(常简称为 DFU)是负责处理从旧版 Minecraft 到新版的地图升级组件。DFU 在 Minecraft 启动过程的极早期阶段就被初始化——事实上,它在游戏窗口出现之前就已经被初始化了。它的架构过于复杂且速度非常缓慢,但这是 Mojang 提供给我们的唯一方案。
作为 DFU 初始化过程的一部分,它会缓存用于从旧版本转换到 Minecraft 各个中间版本直至当前启动版本的所有规则。该过程在后台进行,但_极其缓慢_,因为它既消耗 CPU 又占用大量内存。在 Minecraft 1.16.5 中,我测量出该过程在一台配备 Ryzen 9 3900X 桌面处理器(2019 年发布的高端桌面 CPU)上耗时 9 秒,在一台配备 i5-8250U 的笔记本电脑上(2017 年的中端笔记本芯片)耗时 57 秒。
LazyDFU 所做的只是阻止这一过程——它允许 DFU 初始化,但会强制其不缓存所有这些规则。结果就是,DFU 规则仅在需要转换世界时才会编译。这意味着如果 LazyDFU 强制游戏编译迁移规则,你可能会看到卡顿现象,但一旦完成,就不会有性能惩罚。
证明给我看
我录制了一段视频,展示了 LazyDFU 的效果有多显著。
与其他模组对比
与其他模组相比,LazyDFU 的主要优势在于其_简单_、安全_以及对游戏影响_低。
- LazyDFU 是一个非常简单的模组。整个模组仅有十几行代码,尽可能保持简洁,同时仍能带来巨大的收益。(这也意味着它是一个理想的模组,可用于尝试新的 Mixin 平台!)
- LazyDFU 具有极高的兼容性和安全性。LazyDFU 与其他模组发生冲突的可能性极低。本模组基于 Paper 中的类似补丁,该补丁已使用超过一年,且在迁移到新版 Minecraft 方面未报告任何问题。(此后 Paper 已更改为用其自身高度优化的实现替换 Mojang 的数据修复器。)
LazyDFU is an optimization mod for Minecraft that defers unnecessary initialization work so that it is only performed if required. Specifically, it makes the initialization of DataFixerUpper "lazy" - that is, it will not immediately create the rules required to migrate data from older versions of Minecraft to newer versions until it actually needs to do so.
This mod is for Fabric/Quilt
Compatibility
LazyDFU 0.1.2 is compatible with Minecraft 1.14 through 1.18.2, and works on the client and server side.
LazyDFU 0.1.3 is compatible with Minecraft 1.19 and above, however Mojang now implements the functionality LazyDFU provides on the server side. The client still initializes all DFU rules by default, so LazyDFU hooks into the native client functionality that enables DFU rule baking and turns it into a no-op.
As of Minecraft 1.19.4 and above, however, Mojang has significantly optimized DFU initialization enough that this mod is no longer necessary in many configurations. It will continue to be supported for older versions of Minecraft.
Sponsor me!
Did this mod make Minecraft playable for you? Chip in a bit of money so I can continue developing it.
Why does it work?
DataFixerUpper (often abbreviated to DFU) is the Minecraft component responsible for handling world upgrades from older versions of Minecraft to newer versions. DFU is initialized very early in the Minecraft startup process - in fact, it's initialized before the game window even appears. It is laughably overengineered and very slow, but it's what Mojang gives us to work with.
As part of the DFU initialization process, it caches rules required to convert from older versions to MInecraft through every version in between, up to the version of the game being launched. This process takes place in the background, but it is extremely slow, as it is both CPU and memory intensive. With Minecraft 1.16.5, I have measured this process take 9 seconds on a Ryzen 9 3900X desktop (a high-end desktop CPU released in 2019) and 57 seconds on a laptop with an i5-8250U (a mid-range laptop chip from 2017).
All LazyDFU does is stop this process - it lets DFU initialize, but it will force it to not cache all these rules. As a result, the DFU rules are only compiled when a world needs to be converted. This means it is possible you may see lag spikes if LazyDFU forces the game to compile migration rules, but once complete there is no performance penalty.
Prove it to me
I recorded a video that shows you how effective LazyDFU is.
Comparing it to other mods
In comparison to other mods, LazyDFU has the primary advantage of being simple, safe, and having low impact on the game.
- LazyDFU is a very simple mod. The entire mod is about a dozen lines of code, about as uncomplicated as a mod can get, while still delivering huge benefits. (This means it's also an ideal mod to use to experiment with a new Mixin platform!)
- LazyDFU is highly compatible and safe. LazyDFU is extremely unlikely to conflict with other mods. This mod is based on a similar patch in Paper that had been in use for over a year with no reported issues with migrating to newer versions of Minecraft. (Paper has since changed to replacing Mojang's data fixers with a highly optimized implementation of its own.)
评论 0
登录后参与评分
还没有评论,来抢沙发吧