bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://github.com/bazelbuild/intellij/blob/master/docs/index.md
Apache License 2.0
763 stars 306 forks source link

Slow Operations during Kotlin sync #6874

Open LeFrosch opened 1 month ago

LeFrosch commented 1 month ago

Description of the bug:

Recently I started to notice a lot of slow operations exceptions when running a sync for kotlin targets. Maybe worth looking into.

java.lang.Throwable: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
    at com.intellij.util.SlowOperations.assertSlowOperationsAreAllowed(SlowOperations.java:106)
    at com.intellij.openapi.vfs.newvfs.persistent.FSRecordsImpl.update(FSRecordsImpl.java:727)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.persistAllChildren(PersistentFSImpl.java:398)
    at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.listAll(PersistentFSImpl.java:461)
    at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.loadAllChildren(VirtualDirectoryImpl.java:417)
    at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.getChildren(VirtualDirectoryImpl.java:410)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:313)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:334)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:334)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:334)
    at com.intellij.openapi.vfs.VfsUtilCore.visitChildrenRecursively(VfsUtilCore.java:334)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider$LibraryKindScanner$Companion.runScannerOutsideScanningSession(LibraryEffectiveKindProvider.kt:123)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider.KOTLIN_LIBRARY_KIND_GIST$lambda$3(LibraryEffectiveKindProvider.kt:60)
    at com.intellij.util.gist.VirtualFileGistOverGistStorage.getOrCalculateAndCache(VirtualFileGistOverGistStorage.java:76)
    at com.intellij.util.gist.VirtualFileGistOverGistStorage.getFileData(VirtualFileGistOverGistStorage.java:37)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider$findKind$1.invoke(LibraryEffectiveKindProvider.kt:80)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider$findKind$1.invoke(LibraryEffectiveKindProvider.kt:80)
    at com.intellij.openapi.application.ActionsKt.runReadAction$lambda$3(actions.kt:31)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction$lambda$3(AnyThreadWriteThreadingSupport.kt:219)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction(AnyThreadWriteThreadingSupport.kt:228)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction(AnyThreadWriteThreadingSupport.kt:219)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:852)
    at com.intellij.openapi.application.ActionsKt.runReadAction(actions.kt:31)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider.findKind(LibraryEffectiveKindProvider.kt:80)
    at org.jetbrains.kotlin.idea.base.platforms.LibraryEffectiveKindProvider.getEffectiveKind(LibraryEffectiveKindProvider.kt:101)
    at org.jetbrains.kotlin.idea.base.platforms.KotlinLibraryKindKt.detectLibraryKind(KotlinLibraryKind.kt:91)
    at org.jetbrains.kotlin.idea.base.platforms.StdlibDetectorFacility.isSupported(StdlibDetectorFacility.kt:44)
    at org.jetbrains.kotlin.idea.base.platforms.StdlibDetectorFacility.isStdlib(StdlibDetectorFacility.kt:22)
    at org.jetbrains.kotlin.idea.base.platforms.StdlibDetectorFacility.isStdlib$default(StdlibDetectorFacility.kt:17)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.isKotlinLibrary(KotlinWithLibraryConfigurator.kt:307)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.getKotlinLibrary(KotlinWithLibraryConfigurator.kt:242)
    at org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.getOrCreateKotlinLibrary(KotlinWithLibraryConfigurator.kt:152)
    at com.google.idea.blaze.kotlin.sync.BlazeKotlinSyncPlugin$Listener.lambda$afterSync$0(BlazeKotlinSyncPlugin.java:336)
    at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:229)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread$lambda$1(AnyThreadWriteThreadingSupport.kt:184)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread(AnyThreadWriteThreadingSupport.kt:183)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:836)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:424)
    at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:101)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithImplicitRead(AnyThreadWriteThreadingSupport.kt:122)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1162)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:78)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:119)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:696)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$16(IdeEventQueue.kt:590)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithoutImplicitRead(AnyThreadWriteThreadingSupport.kt:117)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:590)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:73)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:357)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:356)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:356)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:351)
    at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke$lambda$0(IdeEventQueue.kt:1035)
    at com.intellij.openapi.application.WriteIntentReadAction.lambda$run$0(WriteIntentReadAction.java:24)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteIntentReadAction(ApplicationImpl.java:910)
    at com.intellij.openapi.application.WriteIntentReadAction.compute(WriteIntentReadAction.java:55)
    at com.intellij.openapi.application.WriteIntentReadAction.run(WriteIntentReadAction.java:23)
    at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
    at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1036)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1036)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$10(IdeEventQueue.kt:351)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:397)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Which category does this issue belong to?

Intellij

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Sync a kotlin project.

Which Intellij IDE are you using? Please provide the specific version.

No response

What programming languages and tools are you using? Please provide specific versions.

No response

What Bazel plugin version are you using?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

tpasternak commented 1 month ago

https://youtrack.jetbrains.com/issue/KTIJ-28863/KotlinWithLibraryConfigurator.getOrCreateKotlinLibrary-requires-to-be-run-both-under-EDT-and-outside-EDT