-
-
Notifications
You must be signed in to change notification settings - Fork 14
Summary of Patches
A common problem with many performance mods is that the changes they make to the game are unclear. This documentation aims to rectify that by providing an explanation for each mixin option. It is aimed towards mod developers/players familiar with Minecraft internals, although it should still be a useful guide for those trying to understand what the various options in modernfix-mixins.properties
do.
Not all options are available for every Minecraft version, as some patches are only needed on certain versions.
I will try my best to keep this up to date, but some new patches may take a while to get added.
1.16 only. A key optimization. Patches JEI to perform its reloading on a background thread, completely eliminating the long delay it adds to world loading.
1.16 only. Backports the Async Locator mod's patches to eliminate server freezes associated with /locate
, loot table generation, etc.
All versions. If REI or JEI are installed, construction of the vanilla search trees for creative searching is disabled, and searching is instead done using these mods' search implementations. This saves several seconds during world loading, and probably also saves some RAM as well (although I have not measured).
1.16 only. Removes the hardcoded cap on worker thread count, similarly to what Mojang did in 1.18.
All versions. Avoids creating fresh copies of enum arrays each time a blockstate cache is initialized. Minor optimization, but easy to do.
All versions. Memoizes the RenderMaterial
(texture) collection and dependency list that models return instead of requiring them to be recalculated on each request. Helps accelerate the model load/bake process.
All versions. Saves the generated list of stronghold positions with the world, instead of regenerating it on every world load. Saves a little bit of time on 1.16, and quite a bit more on 1.18 and 1.19.
All versions. Many mods ship outdated structure files, which requires the game to upgrade them using DFU every single time they are loaded. This can be quite slow. This patch adds logic to instead save the upgraded version of the structure, and reuse it on the next load. To handle the case that the mod changes a structure file but not the name, the original file's hash is compared against the cached version, and if they do not match the structure will be upgraded again.
1.16 only. Minor optimization borrowed from Hydrogen, which attempts to save space in the biome container when possible. This gets disabled automatically if conflicting mods like BetterEnd or Chocolate are installed.
All versions. Reduces log spam and possibly slightly improves loading speed by not printing the stacktraces for some commonly thrown exceptions during datapack reload (e.g. missing items in loot tables/recipes). The message is still printed.
All versions, but disabled by default due to load time impact. Deduplicates resource location namespaces and paths. This saves RAM but also increases the cost of constructing a new ResourceLocation
by quite a bit.
All versions. Forge needlessly looks up a method via reflection every single time a registry is validated. This patch simply caches the returned value since it will be the same every time.
All versions. These patches aim to optimize the model baking process. The process of building a lookup cache from BlockState
to BakedModel
is now done in parallel. The model bakery also attempts to avoid baking some models at startup if possible, and instead bake them on first use.
1.16 only, disabled by default. An experimental optimization to improve startup efficiency by letting the player join the integrated server before spawn chunks are loaded, in order to kickstart background processes like recipe & tag syncing while the loading screen is being shown. Ultimately I abandoned this as it's more effective to just use Ksyxis, and I have not seen any compatibility issues when doing so.
All versions. Enables the game to use a faster texture stitching system originally written by SuperCoder79 for lwjgl3ify on 1.7.10, which can save some time during loading.
1.16 only. Optimizes Just Enough Resources to not needlessly recreate villager entities many times for the same profession, which saves time during JEI startup.
1.16 only. Optimizations to KubeJS to avoid needless ItemStack
copying, etc., which reduces the time taken to load datapacks.
1.16 only, inspired by Hydrogen. Avoids storing chunk sections that are full of air in memory, instead marking them as empty.
All versions. Despite the name, this option does not (yet) parallelize model loading, although it does load blockstate JSON files from disk in parallel, and implements many microoptimizations to speed this process up as much as possible. Further developments in this area to come.
All versions. A key optimization. Newer Minecraft versions (after 1.12) implemented a blockstate cache system that caches frequently used information about a blockstate, such as whether it is solid, its collision shape, etc. Rebuilding this cache is quite fast in vanilla (it takes only a second or two) but is quite slow with many mods installed, as there are many more blockstates present in the game which all must have their caches rebuilt.
This problem is exacerbated by Forge as the cache is rebuilt at many points when the data would almost certainly be unused before the next rebuild. Examples include right before reaching the main menu (during the "Freezing data" stage), as well as multiple (!) times when a world is being loaded.
ModernFix solves this performance bottleneck by instead making cache rebuilds lazy. Each blockstate rebuilds its cache the first time the data would be accessed. At any point when vanilla or Forge would attempt to rebuild caches for all blockstates, this is redirected to simply invalidate the cache on each blockstate instead.
This should not have any impact on TPS after startup concludes.
All versions. Removes the biome temperature cache as Lithium does on modern versions.
1.16 & 1.18 only. A key optimization. Launches on modern versions are heavily bottlenecked by filesystem access. Many requests are frequently made to resource packs to list resources or check if a given resource exists, and each of these result in a very slow file API call.
ModernFix completely eliminates most of the bottleneck here by simply caching a listing of all resources that exist within mod-provided and vanilla resourcepacks. The cache is rebuilt on resource reload (except for the vanilla resources, since they should never change while the game is running).
There are no known compatibility issues with this patch except for OptiFine (its CTM resources do not load correctly). However I do not recommend using OptiFine in any scenario, as it adds several minutes to launch time by itself and is not tested with ModernFix at all.
1.16 & 1.19 only. A key optimization.
In the middle of the 1.16 development cycle, Forge patched the game to reload datapacks twice when loading an existing world, in order to fix an issue with biome ID shifting. Unfortunately, datapack reloads often take upwards of 30 seconds and so this very severely affects world loading times.
ModernFix makes the necessary changes to avoid this reload, based on the unfinished Forge PR #8163.
This change was removed by Forge in 1.18, but then a similar patch was added again in 1.19 to fix mod datapacks not being loaded when creating new singleplayer worlds. Fortunately, the issue is localized to the world creation screen in 1.19, and existing worlds only require a single reload. However, this still doubles the length of the lag spike when clicking "Create New World" in 1.19, and so ModernFix again makes changes to not perform a redundant reload.
The patches in this group fix concurrency-related issues within Minecraft and/or Forge. Most of them result in rare, hard-to-diagnose crashes during loading.
This option is a port of SuperCoder's Chunk Saving Fix mod (because I didn't realize it was already available for Forge at the time).
This option fixes a deadlock that can occur if an exception is thrown while processing entity data. Vanilla does not correctly unlock the data manager when it should. This is tracked as MC-218112 on the bug tracker, and was fixed by Mojang in 1.17.
Experimental, not enabled by default. An attempted fix for the memory leak issue that occurs after playing long enough on 1.16.
1.16 only, fixes a CME that can occur during worldgen when using newer Java versions.
Patches Twilight Forest to perform non-thread-safe client setup using the main thread as it should, rather than the FML worker thread.
Adds ModernFix to the branding list on the title screen, and also to the F3 screen.
Normally off, can be enabled to force the raw stack trace to be dumped to the log when a crash occurs. Occasionally vanilla's crash report system fails to work properly and gives an entirely irrelevant stack trace/report.
Uses a couple injections to measure world load time, datapack reload time, resource reload time, bootstrap time, and adds the necessary hooks to enable vanilla's unused profiler logic for resource reloading if so configured.