NEI recipe lookup lag
Gamerbolts opened this issue ยท 6 comments
Hi, I am creating a modpack and wanted to add in your mod, I tried it out and realized that pressing R and U in NEI to look up recipes lagged for about 10 to 15 seconds each time I wanted to see a recipe, I take out Traincraft from my modpack and recipes load up instantly. Add back in traincraft and once again 10 to 15 seconds loading.
There is no log since there isn't a crash and nothing comes up in the console when I press R or U. So I am not sure if there is anything that can be done about it, just wanted to let you know.
the issue is the recipes are in a registry that's an enum, so if you want to load any of them, they all have to be loaded.
Given the overall structure of the mod there's nothing that can be done about it till the rewrite.
Does it only load them once, or does it load them every time they are requested? Seems to me that if they don't do the former there aught to be a way to get it to behave like that.
It really depends on the java setup. If java thinks you won't need it again soon, it will toss it from RAM, so it will have to load it again.
And assuming it doesn't toss it, the data still has to be iterated through because it's not indexed, which is a lot of processing.
So that is data that is being tossed into the GC's domain? Would it be possible to engineer something as a singleton, so it gets loaded during inti or postinit, and then stays in RAM all the time?
Not really, given the current system. It's declared as a static variable just from being an enum, but due to the small size enums are supposed to be, in some cases java will just give it to GC.
Unfortunately, this is TC, and our enums are obese, to be polite about it.
In the rewrite I handle it through an indexed switch statement, so there's no iteration, no massive storage, it just gets what it needs when it needs, tosses it when done.