wisp-forest / accessories

A extendable and data-driven Accessory Mod for Minecraft
Other
29 stars 11 forks source link

[1.21] Performance Improvement Suggestions #51

Closed lcy0x1 closed 3 weeks ago

lcy0x1 commented 4 months ago

This is a suggestion on API improvements based on observed performance issue of Curios in 1.20.1

Problem: Too many mods rely on Optional<ItemStack> findFirst(Predicate<ItemStack> predicate) for checking if a player or entity has certain items. This requires iteration over all slots and often cause lag.

Solution: Have some better optimized methods for common use cases

Luillo9642 commented 3 months ago

I don't know if it is related to this, but using this mod makes the ram utilization look like there is a memory leak. It goes at about 1GB/s of RAM or even more. (I went one by one enabling mods until I found out it was this one. I confirmed it by using Spark's profiler.)

Usually, I have RAM usage of around 100MB/s (so as to give a baseline).

If this is not related to this issue, then tell me if so and I will delete the comment and instead open another issue regarding the mod.

P.S. I am writing this regarding the 1.21 Fabric mod. Idk if the same occurs for Forge/NeoForge/other Modloaders. I assume this issue was written by someone using Forge since curios was mentioned instead of trinkets.

Dragon-Seeker commented 3 months ago

I don't know if it is related to this, but using this mod makes the ram utilization look like there is a memory leak.

This more deals with the performance of the most commonly used methods within accessory API and less with possible memory utilization problems though not entirely unrelated to.

A link to the spark profiling combined with a pack break down would be helpful.

Luillo9642 commented 3 months ago

I went through my browser history and got the Spark link for when I did the profiling before removing the mod: https://spark.lucko.me/lqx6xUhO0T

I used the mod view at the top to see which mod was contributing to the lag the most. With the mod view, it shows all mods that were being used at the time.

Hope this helps!

chyzman commented 3 months ago

I've read the spark profile. From what I can gather the profile period is far too low to really signify anything besides possibly Endec being kinda slow when it comes to encoding. There's definitely no memory leak tho.

Luillo9642 commented 3 months ago

Oh. Is there a way to speed that up or something? It somehow makes it so that there is way more ram allocation somehow and it makes it extremely laggy. After removing it, the next new culprit is now Traveler's Backpack. .-. I'mma just assume now that it's just that my MacBook doesn't have enough RAM. It only has 8GB and 1536VRAM since it's integrated graphics. So, yeah. Not that much to work with in the 1st place. Thanks for the reply, though.

chyzman commented 3 months ago

there isn't really any issue with ur pack. It's just the fact ur only giving it 4 gigs of ram. It's not a mod's fault it's just accessories happened to be doing the most things

SettingDust commented 2 months ago

@Luillo9642 There are too many entities in your world. Some commands are running on the entities. https://minecraft.wiki/w/Commands/debug should show you that It's not relating to specific mod I guess

Dragon-Seeker commented 3 weeks ago

An update contains an experimental method of caching lookup to optimize looking through accessories slots