TeamJM / journeymap

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

[Bug]: Directory resourcepacks cause periodic stutters #809

Open DmitriBogdanov opened 2 days ago

DmitriBogdanov commented 2 days 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 2 days 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 day 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?