CodeGPT icon indicating copy to clipboard operation
CodeGPT copied to clipboard

High CPU usage

Open fishermans opened this issue 1 year ago • 1 comments

What happened?

High CPU usage in IntelliJ IDEA 2024.2.2 and 2024.2.3 after installing version 2.10.1-241.1 up to current 2.11.3-241.1. Issue does not occur after downgrading to 2.9.0-241.1.

When opening settings, CPU usage is going down.

image

CodeCompletion is disabled for OpenAI in plugin settings.

Relevant log output or stack trace

"JobScheduler FJ pool 4/15" prio=0 tid=0x0 nid=0x0 runnable
     java.lang.Thread.State: RUNNABLE

	at com.intellij.codeInsight.daemon.impl.HighlightInfoUpdaterImpl.psiElementVisited(HighlightInfoUpdaterImpl.java)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectInformationWithProgress$11(GeneralHighlightingPass.java:192)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$$Lambda/0x0000000802e14958.accept(Unknown Source)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner.lambda$runAnnotator$2(AnnotatorRunner.java:153)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner$$Lambda/0x00000008030f28a0.apply(Unknown Source)
	at com.intellij.codeInsight.daemon.impl.AnnotationSessionImpl.computeWithSession(AnnotationSessionImpl.java:87)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner.runAnnotator(AnnotatorRunner.java:119)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner.lambda$runAnnotatorsAsync$0(AnnotatorRunner.java:66)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner$$Lambda/0x00000008030f1460.run(Unknown Source)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:279)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner.lambda$runAnnotatorsAsync$1(AnnotatorRunner.java:66)
	at com.intellij.codeInsight.daemon.impl.AnnotatorRunner$$Lambda/0x0000000802e3ddd0.process(Unknown Source)
	at com.intellij.concurrency.ApplierCompleter.processArrayItem(ApplierCompleter.java:116)
	at com.intellij.concurrency.ApplierCompleter.processArray(ApplierCompleter.java:196)
	at com.intellij.concurrency.ApplierCompleter.execAll(ApplierCompleter.java:166)
	at com.intellij.concurrency.ApplierCompleter.lambda$exec$0(ApplierCompleter.java:105)
	at com.intellij.concurrency.ApplierCompleter$$Lambda/0x0000000802b72300.run(Unknown Source)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:291)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
	at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$2(ApplierCompleter.java:148)
	at com.intellij.concurrency.ApplierCompleter$$Lambda/0x0000000802b70b60.run(Unknown Source)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
	at com.intellij.openapi.progress.impl.CoreProgressManager$$Lambda/0x00000008015b2910.compute(Unknown Source)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
	at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:159)
	at com.intellij.concurrency.ApplierCompleter.lambda$wrapAndRun$1(ApplierCompleter.java:140)
	at com.intellij.concurrency.ApplierCompleter$$Lambda/0x0000000802b70240.run(Unknown Source)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.executeByImpatientReader(AnyThreadWriteThreadingSupport.kt:486)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:178)
	at com.intellij.concurrency.ApplierCompleter.wrapAndRun(ApplierCompleter.java:140)
	at com.intellij.concurrency.ApplierCompleter.exec(ApplierCompleter.java:108)
	at [email protected]/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at [email protected]/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at [email protected]/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at [email protected]/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at [email protected]/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

Steps to reproduce

Install and open a project.

CodeGPT version

2.11.3-241.1

Operating System

macOS

fishermans avatar Sep 27 '24 14:09 fishermans

It seems to be related to whether a response is available in the page frame. If you delete the response, the CPU load goes down again and “unidentified: JobScheduler FJ pool” is no longer available in the Activity Monitor.

I downgraded to Intellij 2024.1.6. It doesn't happen there. Even completely remove and reinstall 2024.2.3 did not help.

threadDump-20240928-111046.txt

fishermans avatar Sep 28 '24 09:09 fishermans

I'm experiencing this issue as well. Resulting in 800-900% cpu usage on my m3 max. renders intellij unsuable.

codefriar avatar Oct 09 '24 02:10 codefriar

I'm experiencing this issue as well. Resulting in 800-900% cpu usage on my m3 max. renders intellij unsuable.

In the meantime I went back to IDEA 2024.2.1 which seems to work so far.

Since I am working on a Ruby project at the moment, I am using RubyMine 2024.2.3 with CodeGPT latest version without any issues.

fishermans avatar Oct 09 '24 04:10 fishermans

Lately, I have been seeing a lot of JB internal issues related to IDE freezes, I wonder if these two could be related. Anyway, since I'm unable to reproduce this, I have made the first blind attempt by removing the file tracking for temporary files. FileDocumentManager should not be used for our use-cases and I guess it was initially added by mistake.

carlrobertoh avatar Oct 14 '24 13:10 carlrobertoh

I uploaded a pre-release package here: https://github.com/carlrobertoh/CodeGPT/releases/tag/2.11.6-pre I'd really appreciate it if someone could test this out.

carlrobertoh avatar Oct 14 '24 13:10 carlrobertoh

@carlrobertoh Thanks for the Pre-Release.

I tested it on 2024.3 EAP since this issue also exists on 2024.3 EAP and I already dropped 2024.2.3. After update to CodeGPT Pre-Release version the CPU is usage is fine. Maybe, @codefriar can also evaluate this version.

Looks good to me! Thanks for your support!

fishermans avatar Oct 14 '24 15:10 fishermans

There is one thing I noticed since updating to pre release:

Diff isn't working anymore:

java.lang.IllegalStateException: Toolwindow editor file not found at ee.carlrobert.codegpt.util.EditorDiffUtil.createTempDiffFile(EditorDiffUtil.kt:43) at ee.carlrobert.codegpt.util.EditorDiffUtil.showDiff(EditorDiffUtil.kt:30) at ee.carlrobert.codegpt.toolwindow.chat.editor.actions.DiffAction.actionPerformed(DiffAction.java:36) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2314) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:407) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374) at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1029) at java.desktop/com.apple.laf.AquaMenuItemUI.doClick(AquaMenuItemUI.java:157) at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1073) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6665) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3394) at java.desktop/java.awt.Component.processEvent(Component.java:6430) at java.desktop/java.awt.Container.processEvent(Container.java:2266) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5035) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4860) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4963) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4577) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4518) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2810) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4860) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:783) 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.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:755) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:753) 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:752) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:679) at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:621) at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$21(IdeEventQueue.kt:565) at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:87) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:565) at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$18$lambda$17$lambda$16$lambda$15(IdeEventQueue.kt:356) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:844) at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$18$lambda$17$lambda$16(IdeEventQueue.kt:355) at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$2$lambda$1(IdeEventQueue.kt:1047) at com.intellij.openapi.application.WriteIntentReadAction.lambda$run$0(WriteIntentReadAction.java:24) at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:87) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteIntentReadAction(ApplicationImpl.java:922) 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$lambda$2(IdeEventQueue.kt:1047) at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$3(IdeEventQueue.kt:1056) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:117) at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1056) at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$18(IdeEventQueue.kt:350) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:396) 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)

fishermans avatar Oct 16 '24 06:10 fishermans

@fishermans Thanks! This is fixed in the actual release which is also available on the marketplace already.

carlrobertoh avatar Oct 16 '24 08:10 carlrobertoh

Thanks for fixing! LGTM. Final version is working fine! Hence, I am closing this ticket.

fishermans avatar Oct 16 '24 09:10 fishermans