Just Enough Characters

Just Enough Characters

3M Downloads

Just Enough Characters may be consuming more resources than needed

Sunconure11 opened this issue · 9 comments

commented

While profiling to determine the cause of some weird bug I was having, I stumbled upon the fact that your mod is eating up a lot of CPU power, according to VisualVM.

https://www.dropbox.com/s/cegm44xv61kjk92/snapshot.nps?dl=0

commented

I found my computer struggling to run your modpack, but I did some profiling based on packs with over 200 mods. There's no obvious FPS drop noticed, and none of my code detected running in background according to profiler. So I guess there is some conflict with other mods, which is not easy to investigate. Therefore, considering there being no progress for months, I'm going to close this issue. In 1.14, there will be more utilities to validate the issue. Comments are welcomed if any similar issues are detected.

commented

It's actually taking a lot of power. There are some reasons:

  • It replaces JEI's search cache. You know that JEI actually takes a long time to build the cache when game starts, so don't be surprised this mod also takes similar amount of power as replacement of JEI cache, sometimes even more.
  • It replaces vanilla search cache with similar structure. Vanilla's implement is actually faster than JEI's, and mine. But the logic is not compatible with Pinyin search. So it takes several extra seconds when starting game and loading world with this mod. You can disable support for vanilla creative search and recipe book search to save the cost.
  • In older versions, it does matches in real time. In large packs, it takes over 10k match per search request. (Same amount of string.contains invoke without this mod)
  • In very old versions, if you are using much JEI tweaks (like hide item in item list), it will cost some extra time when loading game (about 1min in SevTech).

By the way, this mod also takes much memory in large packs, around 200MB, which is usually smaller than JEI's cache, but much more than vanilla's implement or JEI with FoamFix, which is usually 20MB.

Another reason of wired behaviour might be bugs in upstream because this mod only replaces specific function calls in upstream and have nearly no background execution.

I have been very careful with performance issues and hopefully the cost won't directly lead to your problem. Please let me know if it happens beyond the cases described above, or fixes your problem when removed.

commented

It fixed my problem when removed, which was a massive FPS drop.

commented

Can you provide a minimum environment, or something easy to setup so I can test it?

By the way, I have checked your snapshot. It seems JEI has moved cache construction into background thread and that must be some heavy operations for a while. But I haven't seen anything wired inside my code. Did I miss anything? But for whatever the reason, I will check JEI's new implementation.

commented

If you think you can handle it, you could try the pack of mine in which I discovered the issue in:

https://minecraft.curseforge.com/projects/compitum-magia

commented

I'm pulling it in the next update, though, due to this lag issue.

commented

Can you check this build to see if it fixes the problem?

jecharacters-1.12.0-3.4.4.zip

commented

FPS is no longer as bad as it was in the past, but it could still go with some more refining, as I'm still noticing an FPS drop

commented

The reason for this is JEI will reload the cache in background once config is changed. According to implementation, it takes 40ms per tick (20ms for both tick and post tick) until it's fully reloaded. JEI's cache and mine are not so fast, so it takes some time to process. I noticed you have foamfix installed, which will change JEI cache into vanilla cache. Vanilla cache is faster, making the process less noticeable.

The reloading don't happen unless JEI config is changed by user. I guess it's triggered by some mods that make changes to configs, causing JEI to reload cache every time world starts. In this case, if it only happen in first several minutes the world loads, it's expected and I have no idea how to fix it without breaking other things because it's the default behavior of JEI. My mistake in previous version is no signal triggered when reloading is finished, making the background task never finish.

But if it lasts for a long time, say, over 2 minutes (possibly longer in your pack), I need to further investigate if there is any bug.