GregTechCEu / GregTech

GregTech CE 1.12 fork continuing progression and development
GNU Lesser General Public License v3.0
226 stars 170 forks source link

adjust recipe input expected cache size dynamically #2331

Closed TechLord22 closed 2 months ago

TechLord22 commented 5 months ago

What

Adjusts the ingredient cache size based on previously seen sizes. This will prevent re-hashing the hashset during game load, which will help with memory allocation and subsequent GC action during the game loading process.

This optimization is not targeting CPU or load time, only a reduction in memory allocations and subsequent cleaning.

The default value is enough to not requite a re-hash with base GT alone. This work will primarily see benefits in installations with addons and modpacks creating their own recipes. These benefits will carry forward from modpack development to end users by shipping an updated config file with a final expected cache size.

Implementation Details

This work utilizes the config file as a persistent data storage across game loads. This should maybe be broken out into a separate file with our own handling if desirable.

Outcome

Reduces potential memory allocations for subsequent game loads.

ALongStringOfNumbers commented 4 months ago

Why use a config and not directly save to World Save Data. That way people will not accidentally delete the file, modpack makers don't have to worry about shipping the file, and it takes advantage of an existing implementation within MC instead of us having to write our own.

The only issue is that it will not be applied when first creating the world, but will have to wait until future joining of the world.