Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heavy lag when using a ME Crafting Interface; constantly recalculating EMI's "craftables"? #23

Open
unilock opened this issue Mar 20, 2024 · 11 comments
Labels
bug Something isn't working fixed-at-dev This problem is already fixed on the development branch

Comments

@unilock
Copy link

unilock commented Mar 20, 2024

When AE2 EMI Crafitng Integration is installed in my (very large) modpack, the game repeatedly freezes every time I do something in an AE2 ME Crafting Interface. (moving items into the crafting grid, taking items out of the crafting grid, etc.)

From a log generated with spark, it seems to be constantly recalculating EMI's "craftables"? https://spark.lucko.me/ZgK1KYyjaO

latest.log: https://gist.github.com/unilock/61cf7f486d325f3a8f1c19efed2b10ad

Note that AE2's built-in JEI integration appears to work fine via JEMI, so I've been relying on that instead.

@alikindsys
Copy link
Contributor

oh lord. try disabling that feature until I optimize it, the latest version has an option to disable emi syncing which also disables this code path iirc. if it doesn't just downgrade to 1.3.0 since that version doesn't have that feature added.

can you also give me your modpacks/mod list for testing on something that stresses the mod out?

@Ftrless
Copy link
Contributor

Ftrless commented Mar 21, 2024

Btw I noticed this too, only on older versions mod, at that point I just put it in a separate thread and it helped

@unilock
Copy link
Author

unilock commented Mar 21, 2024

the latest version has an option to disable emi syncing

I've already been testing with "BOM Syncing" disabled, unfortunately.

if it doesn't just downgrade to 1.3.0 since that version doesn't have that feature added.

If I remember correctly, I had the same(? or at least a similar) problem on older versions of the mod as well.

can you also give me your modpacks/mod list for testing on something that stresses the mod out?

Here's a recent Prism Launcher export of the modpack I'm using: https://mega.nz/file/xssEBaZZ#8loKITZKbzxVISOCC_dVoMdLnjIpUYk6EebYHmXVRPI
(it may need AE2 EMI Crafting Integration re-added)

@alikindsys
Copy link
Contributor

The issue here is really wierd, since the hot path is caused by ae2's findMissingIngredients. Craftables aren't what is being recalculated here, and honestly nothing should be recalculated.

The problem is, in modpacks with a lot of crafting recipes, EMI will check the craftability of each one of those recipes with the canCraft function, which is implmemented in the same way as the official AE2 extension afaik (or at least it was once i was backporting their mod integration).

They since changed to fix to only use the findMissingIngredients logic if you are pressing the fill button. If the context is part of the api for 1.20.1 and earlier i can fix that cleanly, otherwise that will break the searching for recipes logic.

    @Override
    public boolean canCraft(EmiRecipe recipe, EmiCraftContext<T> context) {
        if (context.getType() == EmiCraftContext.Type.FILL_BUTTON) {
            return transferRecipe(recipe, context, false).canCraft();
        }
        return StandardRecipeHandler.super.canCraft(recipe, context);
    }

@alikindsys
Copy link
Contributor

This should fix the lag since this version has their fix. the only thing that might got broken was that the craftables tab wont see the contents of the ME system, regardless of bom sync value. If this fixes the problem i'll reimplement the syncing later.

ae2-emi-crafting-1.3.1-dev.zip

@Ftrless
Copy link
Contributor

Ftrless commented Mar 21, 2024

    @Override
    public boolean canCraft(EmiRecipe recipe, EmiCraftContext<T> context) {
        if (context.getType() == EmiCraftContext.Type.FILL_BUTTON) {
            return transferRecipe(recipe, context, false).canCraft();
        }
        return StandardRecipeHandler.super.canCraft(recipe, context);
    }

This implementation also breaks grid filling when you click on the desired craft rbm with shift held down (at least at me)

@Ftrless
Copy link
Contributor

Ftrless commented Mar 25, 2024

@unilock there any results?

@unilock
Copy link
Author

unilock commented Mar 25, 2024

This should fix the lag since this version has their fix. the only thing that might got broken was that the craftables tab wont see the contents of the ME system, regardless of bom sync value. If this fixes the problem i'll reimplement the syncing later.

This build does appear to fix the problem, thanks! (Note that I personally do not use the "craftables" tab, so that remains untested.)

@alikindsys
Copy link
Contributor

alikindsys commented Mar 25, 2024

I can't test unilock's modpack due to hardware limitations. I've reduced the amount of calls to the offending function and that should make it 3x less laggy. I'll likely put that under a toggle since it should only ever be a problem with really large packs (and this is likely an issue with forge in specific since this mod is used on a large lunapixel studio modpack).

IIRC forge did a lot of changes to minecrafts vanilla registry in order to load mods multithreaded (in an attempt to make mod loading faster) and those changes could also be what causes the lag. I'd have to properly support forge to see if that fixes the problem since connector could try as they might to make fabric mods load on forge but there will be edge cases and I'm inclined to believe this is one of them.

@alikindsys alikindsys added bug Something isn't working fixed-at-dev This problem is already fixed on the development branch labels Mar 25, 2024
@alikindsys
Copy link
Contributor

Fixed

Dev: baccca2
MR: Waiting for Release
CF: Waiting for Release

@NickAcPT
Copy link

Fixed

Dev: baccca2 MR: Waiting for Release CF: Waiting for Release

@roridev I've been hitting this issue for a while now with a modpack I'm playing with some friends.

Is there any ETA on a version bump?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-at-dev This problem is already fixed on the development branch
Projects
None yet
Development

No branches or pull requests

4 participants