FastPackLoad
原版在渲染线程上执行了大量不必要的资源包处理工作。当使用包含大量内容的服务器资源包时,你在加入或切换服务器时会遇到持续数秒的卡顿,有时甚至长到让 Windows 将窗口标记为“无响应”并变灰。
FastPackLoad 移除了大部分此类工作。
它改变了什么
包发现并行运行。 原版在主线程上一次一个地打开每个包并解析其元数据,甚至在加载界面出现之前就已经开始。
Zip 格式的包只索引一次。 每当重载器询问某个资源文件夹时,原版都会遍历整个归档文件,并在每次遍历时重建和解码每个条目名称。
字体处理脱离渲染线程。 字形覆盖范围在多核上解决,并且当涉及数百个字体时,完全采用不同的算法进行解决。如果资源包中不包含 TrueType 字体,则跳过仅对 TrueType 字体有效的预热循环。
Atlas 纹理的多级渐远纹理(mipmaps)在多核上生成。 原版在一个工作线程上的单个任务中构建每个精灵的所有多级渐远纹理,而重载池中的其他线程无事可做。
加载界面不再干等。 完成的重载仍然会经历一段宽限期和淡入效果,最多有三秒钟毫无意义的等待。这是一个行为变更,因此它有自己独立的开关。
修复了原版的竞态条件。 包读取器中懒加载的 ZipFile 句柄未同步,尽管重载过程同时从多个线程读取包。这可能导致每次竞态都泄漏一个文件句柄,或者将一个刚被其他线程关闭的归档文件交给读取器,从而在加载中途表现为 IllegalStateException: zip file closed。
实测数据
在一个提供 746 个字体提供者的服务器资源包上:
| 优化前 | 优化后 | |
|---|---|---|
| 渲染线程冻结时间 | 4384 毫秒 | 448 毫秒 |
| 完整重载时间 | ~7.2 秒 | ~3.7 秒 |
你的实际数值可能会有所不同。字体较少的资源包收益较小。
何时仍会发生卡顿
看门狗采样渲染线程,如果帧停止到达,它会记录当前卡住的堆栈以及该堆栈指向的资源包。每次重载还会记录简短摘要,说明是什么导致了阻塞以及阻塞了多久,从而可以针对导致缓慢的具体资源包进行分析,而不是盲目猜测。
注意事项
仅限客户端;服务器端无需任何操作。不依赖 Fabric API。如果需要排查问题,可以在 config/fastpackload.json 中单独关闭每一项更改。
FastPackLoad
Vanilla does a lot of unnecessary resource pack work on the render thread. With a large server pack that shows up as a multi-second freeze when you join or switch servers, sometimes long enough for Windows to grey the window out as "not responding".
FastPackLoad removes most of that work.
What it changes
Pack discovery runs in parallel. Vanilla opens every pack and parses its metadata one at a time, on the main thread, before the loading screen even appears.
Zip packs are indexed once. Vanilla walks the whole archive every time a reloader asks about a resource folder, rebuilding and decoding every entry name on each pass.
Font work comes off the render thread. Glyph coverage is resolved across cores, and with hundreds of fonts it is resolved by a different algorithm entirely. A warm-up loop that only does anything for TrueType fonts is skipped when a pack has none.
Atlas mipmaps are generated across cores. Vanilla builds every sprite's mipmaps in a single task on one worker, while the rest of the reload pool has nothing to do.
The loading screen stops waiting around. A finished reload still sits through a grace period and a fade, up to three seconds of nothing. That one is a behaviour change, so it has its own switch.
A vanilla race is fixed. The lazy ZipFile handle in the pack reader is unsynchronised,
even though a reload reads packs from several threads at once. That can leak a file handle
per race, or hand a reader an archive another thread just closed, which surfaces as
IllegalStateException: zip file closed part-way through loading.
Measured
On a server whose pack ships 746 font providers:
| before | after | |
|---|---|---|
| Render thread frozen | 4384 ms | 448 ms |
| Full reload | ~7.2 s | ~3.7 s |
Your numbers will differ. Packs that are light on fonts have less to gain.
When it still freezes
A watchdog samples the render thread and, if frames stop arriving, logs the stack it is stuck in, along with the package that stack points at. Every reload also logs a short summary of what blocked and for how long, so a slow pack can be pointed at instead of guessed about.
Notes
Client-side only; nothing is required on the server. No Fabric API dependency. Every change
can be switched off individually in config/fastpackload.json if you need to rule something
out.
下载 FastPackLoad
下载 FastPackLoad
下载 FastPackLoad
下载 FastPackLoad
下载 FastPackLoad
下载 FastPackLoad
新增对 Minecraft 26.3 的支持。
增加了对 Minecraft 26.1、26.1.1、26.1.2 和 26.2 的支持。 加载速度再次提升。之前即使你的核心处于空闲状态,包文件也会被逐个读取,而现在不再如此。准备纹理的工作量也大大减少。
如果你使用的是 26.1 或更高版本,请注意以下两点:cachePackMetadata 设置在这些版本中已无效,因为 Minecraft 现在自行处理该功能。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
原版世界生成优化模组
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
缓冲的原始输入和线程化的事件轮询
评论 0
登录后参与评分
还没有评论,来抢沙发吧