Cyclops Core

Cyclops Core

111M Downloads

CapabilityConstructorRegistry.onItemStackLoad seems slow

mezz opened this issue ยท 5 comments

commented

Issue type:

  • ๐ŸŒ Performance issue

Short description:

Steps to reproduce the problem:

  1. Sample startup of All The Mods 3 pack.
  2. Observe about 14 seconds of loading time is spent in CapabilityConstructorRegistry.onItemStackLoad.

Versions:

  • This mod: 0.11.6
  • Minecraft: 1.12.2
  • Forge: 14.23.4.2745
    (note I had to update CoFHCore to 4.5.3.20 to use this Forge version in the pack)

Profiler output:

CyclopsCoreOnItemStackLoad.zip

commented

I have not received any more performance issues related to this. So the recent CyclopsCore and Forge(?) changes probably made things sufficiently performant.

commented

Thanks for reporting! I was already planning on looking into this soon, as we noticed an issue with this on FC as well.

According to cpw, the main performance issue is not the method itself, but its typed Forge event bus registration.

Note to self: deprecate CapabilityConstructorRegistry.onItemStackLoad, as it's not really needed anyways (I think).

commented

Hmm that's interesting. I didn't see anything in your code that seemed slow, so it makes sense that the generic event bus subscription is taking the time.
In general Item#initCapabilities is best, the event is good for attaching capabilities to other mod's items.

As a temporary solution, can move the onItemStackLoad subscription to a separate class, and only subscribe it to the event bus if something using CyclopsCore needs it?

commented

As a temporary solution, can move the onItemStackLoad subscription to a separate class, and only subscribe it to the event bus if something using CyclopsCore needs it?

Yep, that's a good idea. Will look into it soon.

commented

CyclopsCore 0.11.9 contains a change that will only register cap inject listeners to the event bus when needed.

However, this unfortunately won't change anything in the majority of modpacks that include CyclopsCore. Because most of them also include CommonCapabilities, which injects 3 ItemStack capabilities into vanilla, so the listener is registered there in any case.

When I find some time, I might do some digging around into Forge to see if there's anything that can be made more performant there.