Discord: https://discord.gg/BCHNhsDMXz
This mod provides game loading time break down and per-mod loading time.
The analysis of loading time is purely based on code usage, so resource loading (block models), mixins, and fabric mods (if you use sinytra) will be calculated as part of vanilla loading time.
Do not load existing worlds with this mod. Due to the intrusive nature of this mod, it might not be compatible with some mods during world load. This mod should only be used for profiling and analyzing purpose.
Game loading has 3 primary phases:
In this phase, Forge Mod Loader will initialize the necessary services, such as accesstransformer, coremod, mixins, and this mod. During this phase, there will be a primary scanning of mod files, but mods without services will not be loaded. This mod breaks this phase into 5 stages:
In this phase, minecraft and mod code starts loading. It's split into 17 stages due to the fact that any of those stages can be significantly altered by mixins. Having the detailed breakdown available will help to identify cause of slow loading.
In this phase, tasks are being collected and executed in parallel. There will be a detailed profile of how long does each of the tasks take. The total time of all tasks might be shorter than the reload process, and the ratio will be your thread utilization rate. If you have a utilization rate of 400%, that means 4 CPUs are running in parallel nonstop to process all the tasks so that you spend 30 seconds to finish tasks that takes 120 second to run if it's run by 1 CPU.
Notably, the slowest task here should be ModelManager. ModelManager is responsible for loading all the block models in the game, and this process is broken down into 10 stages.
Once you run the game with this mod, it will generate a profile report at logs/profiler/loading-<time>.txt.
There are 2 sections in the report: Summary and Detail. Summary is the abbrevated version of the detail, so I will only explain the detail part.
This section shows the duration of of phase 1 (mod launcher initialization) and phase 2 (minecraft bootstrap) stages. There are 22 stages in total here. Usually the slow stages should be:
Example format:
Game takes <xxx> seconds to bootstrap
<Stage>: <xxx> ms
...
This section displays the total execution time to complete all tasks, and individual task execution time. General tasks will be displayed first, and then mod-specific tasks. In detailed view, there will be 2 numbers displayed for each task: main thread time and total thread time. Main thread time refers to time taken for tasks to be executed in the main thread, for things than cannot be run in parallel, such as modifying data of game objects. Total thread time refers to the total time this task occupies the CPU for. It could be longer than total execution time if this task is being broken into multiple pieces executed by multiple CPUs at the same time.
Example format:
Reload Manager takes <xxx> seconds, loading <xxx> tasks
Tasks are processed in parallel using multiple threads.
- <Task>: <main thread time> / <total time>
...
Misc <xxx> Tasks: <xxx> ms / <xxx> ms
Model Analyzer: <xxx> ms / <xxx> ms
Main thread utilization: xx%
Off thread utilization: xx%
Idle time: <xxx> ms
Misc Tasks refers to tasks that takes very short time to run. It will be too much of a bloat to display all of them, so I display only a sum of all those tasks here.
Model Analyzer is a task this mod adds to analyze the origin of models. I will help to show which mod is adding a lot of models to load if you find it taking too long. This task should be taking <10% of ModelManager's time.
Main thread utilization: how much the main thread is being used for loading tasks. If you find it being high, that means that there are mods executing slow tasks in main thread, which should not happen.
Off thread utilization: effectively how many CPUs are being used to execute all the tasks
Idle time: time where none of the tasks are running. Could be caused by mods assigning wrong executor to run their tasks, causing this mod not able to tell who is running.
This sections display the time for each mod to initialize and load. Please note that this only takes account for mod construction and mod events. Mixins and Fabric mods are not accounted for here.
Mods taking longer than 0.1 seconds will be listed, and mods taking longer than 1 second will have details listed as well. The detail will include construction time (which is usually the longest) and mod event time (mods usually do work during each of the events so that they happen at the right time).
Example format:
Mods use <xxx> seconds to initialize
(Explanations)
Mods use <xxx> seconds to load
Mod init takes <xxx> seconds CPU time. Thread utilization: xx%
- <modid>: <xxx> ms
| - <process>: <xxx> ms
- <modid>: <xxx> ms
Misc <xxx> mods: <xxx> ms
This section shows the time breakdown of the 10 model manager loading stages.
Stage "Adding modded special models" and "Mods altering models" is usually very fast, but could potentially be slow if mods are havily adding modiying block models.
Example Format:
Model Load Time per Stage:
- <Stage>: <xxx> ms
Found <xxx> packs
Loaded <xxx> model files with total size of <xxx> KB
Baked <xxx> models
- <mod jar or resource pack zip>: <xxx> KB
Misc <xxx> packs: <xxx> KB