singlehotswap icon indicating copy to clipboard operation
singlehotswap copied to clipboard

Kotlin hotswap significatly slower than java

Open NopoTheGamer opened this issue 1 year ago • 8 comments

unsure if this is a bug or a limitation of kotlin

Java image

Kotlin image

NopoTheGamer avatar Dec 21 '24 05:12 NopoTheGamer

experiencing same issue

AquaMinerale2b2t avatar Aug 10 '25 22:08 AquaMinerale2b2t

Do you have a sample project that I can use to test it?

LabyStudio avatar Aug 10 '25 23:08 LabyStudio

I made a basic Minecraft 1.21.4 frabic mod to showcase it. Classes RendererKotlin.kt and RendererJava.java were used for the test hotswapping with identical changes being made to them. I was using SingleHotswap 2.10, Intellij Community Edition 2025.1, Kotlin 2.2.0, Java 21, Windows 10 system, i5 11400 CPU.

https://github.com/AquaMinerale2b2t/example

Image

While the speed detriment is apparant in my testing, the issue seems to be dramatically exacerbated in large projects, with copile times for a single class sometimes exceeding 40 seconds. Let me know if you need different samples to conduct your testing.

AquaMinerale2b2t avatar Aug 13 '25 11:08 AquaMinerale2b2t

I made a basic Minecraft 1.21.4 frabic mod to showcase it. Classes RendererKotlin.kt and RendererJava.java were used for the test hotswapping with identical changes being made to them. I was using SingleHotswap 2.10, Intellij Community Edition 2025.1, Kotlin 2.2.0, Java 21, Windows 10 system, i5 11400 CPU.

https://github.com/AquaMinerale2b2t/example

Image While the speed detriment is apparant in my testing, the issue seems to be dramatically exacerbated in large projects, with copile times for a single class sometimes exceeding 40 seconds. Let me know if you need different samples to conduct your testing.

Thanks a lot! But I think your project is set to private 😅

LabyStudio avatar Aug 13 '25 12:08 LabyStudio

Oops! Should be fixed now

AquaMinerale2b2t avatar Aug 13 '25 12:08 AquaMinerale2b2t

Sorry for the long wait. I spent some time implementing a custom Kotlin compiler in the plugin, but I couldn’t make it run any faster. My implementation calls the Kotlin compiler directly with the files you want to hotswap, and even then, it was still insanely slow.

Even a simple compile test in the console shows a huge difference: Image

I don't really know how to improve it...

LabyStudio avatar Oct 15 '25 06:10 LabyStudio

You can try if it works for you singlehotswap.zip

LabyStudio avatar Oct 15 '25 07:10 LabyStudio

You can try if it works for you singlehotswap.zip

I think this version is even slower

loqqin avatar Nov 12 '25 19:11 loqqin