kotest / kotest-intellij-plugin

The official Kotest plugin for Intellij and Android Studio
Apache License 2.0
179 stars 25 forks source link

Slow typing performance on test files #184

Closed LimmaPaulus closed 2 years ago

LimmaPaulus commented 2 years ago

Hi,

Typing performance suddenly got unusable slow when editing Kotest-files with plugin enabled. I don't know if this was consequence of some unattended version update. I'm using IntelliJ 2021.2.4 and plugin version 1.1.50-IC-2021.2.3.

Related IntelliJ issue with CPU profiler dump: https://youtrack.jetbrains.com/issue/IDEA-295228

LimmaPaulus commented 2 years ago

Any comments or similar experiences? Editing test files is pretty much impossible for me currently.

wfhartford commented 2 years ago

I'm experiencing similar issues with IDEA 2022.1.2 and Kotest plugin 1.1.57-IC-2022.1

sksamuel commented 2 years ago

@LimmaPaulus I don't see the cpu dump in that ticket ?

LimmaPaulus commented 2 years ago

IU-212.5712.43_paulus_02.06.2022_10.07.30.zip

Here it is. This is a dump got by "Start CPU usage profiling" button.

LimmaPaulus commented 2 years ago

Closing the issue as the problems seems to been disappeared at least for me.

wfhartford commented 2 years ago

I am still experiencing significant lag when editing moderately large kotest test classes when the IDEA extension is enabled.

wfhartford commented 2 years ago

I've tested with the most up-to-date IDEA 2022.1.3 and up-to-date plugin 1.2.58-IC-2022.1 as well as with the current IDEA EAP and EAP version of the plugin. In both configurations, I experience significant lag when editing a test file of about 300 lines. The lag is not noticeable with very small files, but gets worse the larger the file is.

sksamuel commented 2 years ago

And if you remove the plugin and restart, it's good?

Do you have a sample file? You could obfuscate the names if it's sensitive.

On Thu, Jun 30, 2022, 11:18 AM Wesley Hartford @.***> wrote:

I've tested with the most up-to-date IDEA 2022.1.3 and up-to-date plugin 1.2.58-IC-2022.1 as well as with the current IDEA EAP and EAP version of the plugin. In both configurations, I experience significant lag when editing a test file of about 300 lines. The lag is not noticeable with very small files, but gets worse the larger the file is.

— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-intellij-plugin/issues/184#issuecomment-1171534073, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGQ2CSFP4FPIY2W4NRLVRXQGXANCNFSM5XUAELSQ . You are receiving this because you commented.Message ID: @.***>

wfhartford commented 2 years ago

Yes, disabling the plugin and restarting resolves the lag issue. Removing the plugin is not necessary, just disabling. Restarting is necessary, the lag remains after disabling the plugin until IDEA is restarted.

This is a large kotest file using FunSpec, when I edit anywhere in this file in IDEA with the kotest plugin enabled, it's very laggy. I don't think there is anything special about this file; the many contexts aren't really necessary, only the size, which is large, but not unrealistic. LaggyTestSpec.txt

sksamuel commented 2 years ago

Thanks, this is a good reproduction. I'll see what happens on my machine. What's your system setup (os, cpu)

On Fri, 1 Jul 2022 at 10:53, Wesley Hartford @.***> wrote:

Yes, disabling the plugin and restarting resolves the lag issue. Removing the plugin is not necessary, just disabling. Restarting is necessary, the lag remains after disabling the plugin until IDEA is restarted.

This is a large kotest file using FunSpec, when I edit anywhere in this file in IDEA with the kotest plugin enabled, it's very laggy. I don't think there is anything special about this file; the many contexts aren't really necessary, only the size, which is large, but not unrealistic. LaggyTestSpec.txt https://github.com/kotest/kotest-intellij-plugin/files/9030090/LaggyTestSpec.txt

— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-intellij-plugin/issues/184#issuecomment-1172483805, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGW4T7R4R5HERK5YD7DVR4IADANCNFSM5XUAELSQ . You are receiving this because you commented.Message ID: @.***>

wfhartford commented 2 years ago

Linux (Pop_OS!) AMD Ryzen 9 3900 12-Core Processor 64GB RAM 16GB Heap for IDEA

sksamuel commented 2 years ago

Should be plenty fast :)

On Fri, 1 Jul 2022 at 14:55, Wesley Hartford @.***> wrote:

Linux (Pop_OS!) AMD Ryzen 9 3900 12-Core Processor 64GB RAM 16GB Heap for IDEA

— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-intellij-plugin/issues/184#issuecomment-1172670493, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGUJVZYOU66H3YPFZYLVR5EMBANCNFSM5XUAELSQ . You are receiving this because you commented.Message ID: @.***>

sksamuel commented 2 years ago

I do see the analyzing phase taking a long time, but I tried disabling all the parts of the plugin and it's no different. I think just the latest Kotlin plugins often have regressions in terms of performance. And I wonder if the kotlin plugin isn't great with lots of nested lambdas (it certainly used to be slow in this area).

knizamov commented 2 years ago

@sksamuel I just bumped the issue on youtrack and got the following response. Do you think there is still something that Kotest plugin can do?

https://youtrack.jetbrains.com/issue/IDEA-295228

Dmitry Jemerov commented 11 minutes ago

In the attached snapshot, the majority of the time is spent in the specStyle method of the Kotest plugin code, so the problem is clearly caused by the Kotest plugin, not by any performance problems of the Kotlin plugin itself.

Screenshot 2022-09-20 at 18 01 06
sksamuel commented 2 years ago

I've replied on the thread. I don't see how that screenshot shows that spec style is the culprit here. Also how do you generate those ?

On Tue, 20 Sept 2022 at 11:12, Kirill Nizamov @.***> wrote:

@sksamuel https://github.com/sksamuel I just bumped the issue on youtrack and got the following response. Do you think there is still something that Kotest plugin can do?

https://youtrack.jetbrains.com/issue/IDEA-295228

In the attached snapshot, the majority of the time is spent in the specStyle method of the Kotest plugin code, so the problem is clearly caused by the Kotest plugin, not by any performance problems of the Kotlin plugin itself.

[image: Screenshot 2022-09-20 at 18 01 06] https://user-images.githubusercontent.com/18502510/191309958-7636e7db-4d89-4f37-94b0-cd3bfc1defc6.png

— Reply to this email directly, view it on GitHub https://github.com/kotest/kotest-intellij-plugin/issues/184#issuecomment-1252584582, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGXZAUMRYGVU3XP5QF3V7HPADANCNFSM5XUAELSQ . You are receiving this because you were mentioned.Message ID: @.***>

knizamov commented 2 years ago

I'm also not aware of those flame graphs and how to generate them (also, maybe he meant SpecsKt.specs part in the bottom, maybe the wrong part is highlighted due to cursor).

And maybe after all, the Kotest plugin doesn't impact performance as much (although I feel like it has some less noticeable impact).

What I noticed is that using init block instead of init lambda makes autocompletion much more performant and responsive, and it doesn't matter much whether the Kotest plugin is enabled or disabled in this case. I recorded some video clips and attached them to the youtrack issue https://youtrack.jetbrains.com/issue/IDEA-295228/Slow-typing-performance-when-using-Kotest-plugin#focus=Comments-27-6461505.0-0

So, I guess I will migrate to init block style spec declaration for the time being.

wfhartford commented 2 years ago

Thanks for mentioning the init block option @knizamov . I'm not seeing any performance issues after changing my tests to that style.