Skip to content

Fix mixin autocomplete spinning indefinitely in classes with many lambdas#2596

Open
embeddedt wants to merge 1 commit intominecraft-dev:devfrom
embeddedt:optimize-lambda-search
Open

Fix mixin autocomplete spinning indefinitely in classes with many lambdas#2596
embeddedt wants to merge 1 commit intominecraft-dev:devfrom
embeddedt:optimize-lambda-search

Conversation

@embeddedt
Copy link

In large classes with many lambdas (e.g. Minecraft 1.20.1 ChunkMap/Minecraft/etc) mixin autocomplete for filling in at of @Inject(at = "...") stops working. More precisely, from profiling and dumping thread states, it appears to get stuck doing a ton of Psi resolution work in hasSyntheticMethod.

The cleanest approach I was able to find is to adjust the lambda counting code so that the indexes stored in SourceCodeLocationInfo can be used without requiring the expensive hasSyntheticMethod check in the Psi visitor. This reduces the work done during visiting to just the Matcher's counting, which is not really super efficient either, but fast enough not to be an issue for interactive editing.

hasSyntheticMethod is now unused, but I've left it in place for the time being since it's a utility method. (Happy to remove if desired.)

Note: in the interest of full disclosure, the analysis for this problem was done in collaboration with an LLM. The fix appears straightforward and I have confirmed that it solves the problem. That said, the ASM/Psi analysis code here is quite complex and it's possible that changing the meaning of lambdaCount as done here may have broken something inadvertently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant