TeamJM / journeymap

JourneyMap mod for Minecraft
http://journeymap.info
132 stars 10 forks source link

[Bug]: Directory resourcepacks cause periodic stutters #809

Closed DmitriBogdanov closed 4 weeks ago

DmitriBogdanov commented 1 month ago

What happened?

Issue

With directory resourcepacks enabled and a lot of entities present in the vicinity, JourneyMap causes noticeable stutters every few seconds. This stops being the case if the same resourcepacks are zipped.

Environment

Minecraft version: 1.20.1 Modloader: Fabric 0.16.17 (latest) Modlist:

Reproducing

Prepare several large resourcepacks. I've got the same set in both directory- and zip- formats:

pack_list

Spawn a whole bunch of entities (about few hundred chickens in this example, but the stutters are noticeable even with rather small numbers):

chickens

Enable all directory packs. Run /sparkc profiler start --timeout 60 --only-ticks-over 120 and run around for a while, there will be occasional long stutters and the profile logs will contain several long ticks with JourneyMap taking the vast majority of time seemingly looking for mob icons:

https://spark.lucko.me/SVMJWuArCF

profiler_dir_1 profiler_dir_2 profiler_dir_3

Disable directory packs, enable their zipped version. Do the same thing as above. Now, the stutters are gone and there are no long ticks detected by the profiler:

https://spark.lucko.me/prTqiYH4Oh

profiler_zip

Notes

Mod Loader

Fabric

Minecraft Version

1.20.1

Version

5.10.0

Relevant log output

journeymap.log latest.log

mysticdrew commented 1 month ago

I can look at optimizing this in future versions, unlikely to come in 1.20.1 as we are moving on to newer versions now.

I probably don't want update the icons unless there has been a pack updated so we only look for the file once per entity type. Directory/Folder resource packs is something I have never tested and honestly, I thought it was required to be in a zip file. TIL.

It is not an issue with zips because they are fully loaded in memory. So lookups are a non issue, but if Mojang is doing a file exists every lookup, that is bad.

DmitriBogdanov commented 1 month ago

It seems I was not entirely correct about ZIP resourcepacks not causing the stutters, it's just less severe so it wasn't noticeable on a leaner test instance.

Doing the same on a heavier instance with ~500 MB of zipped-only resourcepacks (mostly audio, skyboxes and hi-res GUI textures) still causes the stuttering, though it is not as bad as it was with folder packs:

https://spark.lucko.me/74KRoPyu5B

profile_0 profile_1 profile_2

It seems a little bizzare that the minimap is even trying to look for icons, considering mob icons are disabled in settings. Perhaps the whole thing can only run once on a resource load and toggle the lookup off completely in case they are disabled?

mysticdrew commented 1 month ago

We cannot replicate this issue on our end.

Can you see if you have a similar issue in 1.21.1-6.0.0.beta.28?

DmitriBogdanov commented 1 month ago

Could not replicate with MC 1.21.1 + Fabric 0.16.8 + JourneyMap 6.0.0-beta.28, even when running the same set of directory resource packs that caused extreme stuttering on 1.20.1.

Ran the same map on newly created MC 1.20.1 + Fabric 0.16.7 + JourneyMap 5.10.3 instance just to check again - yep, the problem is still here.

Perhaps this has something to do with vanilla changes or the upgrade from Java 17 to Java 21 in the newer MC versions.

DmitriBogdanov commented 1 month ago

Unfortunately, testing whether it is the Java runtime or the vanilla MC implementation that is the bifurcation point proves rather difficult since 1.20.1 doesn't run under Java 21 and 1.21.1 doesn't run under Java 17, but regardless, for the completeness here are the JRE versions used for both instances:

MC 1.20.1 Java 17 runtime:

openjdk version "17.0.8" 2023-07-18 LTS
OpenJDK Runtime Environment Microsoft-8035246 (build 17.0.8+7-LTS)
OpenJDK 64-Bit Server VM Microsoft-8035246 (build 17.0.8+7-LTS, mixed mode)

MC 1.21.1 Java 21 runtime:

openjdk version "21.0.2" 2024-01-16 LTS
OpenJDK Runtime Environment Microsoft-8905927 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Microsoft-8905927 (build 21.0.2+13-LTS, mixed mode)

...or perhaps it was simply one of the JourneyMap updates in-between that fixed it, whatever the case it doesn't seem to happen in the new version.

mysticdrew commented 4 weeks ago

This is good news that it works with 6.0.0. The bad news is that I am no longer updating version 5.x of JM anymore.

Thanks for taking the time and reporting this with your analysis.