since last 5 months, after working with my IntelliJ for a while, suddenly it gets all of my CPU and my pc become so slow that I must kill the IntelliJ and restart it to make it work again.
I had this issue on my windows 10 and also after upgrading to 11, first I thought it might be a problem with my windows. recently I reinstall a fresh version of windows 10 and saw this still happening, I disabled my most plugins but only when I disabled sonarlint it fixed my problem.
I try to monitor my CPU and get snap-shot with java tools like jconsole, etc but it happens so randomly (some times after 20 min some times after 5 hours of work; I must see it after awaking my pc from a sleep state with an open IntelliJ). also when it happens most programs hang so I couldn’t catch any snap-shot.
my system specs:
ram: 32GB DDR4
cpu: ryzen 3900x (12 cores, 24 threads)
Thanks for the feedback.
Could you please give us more details about your situation, in case we see something interesting:
- version of SonarLint
- version of IntelliJ
- your project type/languages (Java ? JS/TS ?)
- are you using connected mode with SonarQube or SonarCloud?
the version of SonarLint: I always use your latest version, in this case, I guess I’ve used all the latest versions since 5 month ago, and right now I have version 22.214.171.124541
the version of IntelliJ: the same thing is true for IntelliJ, but I remember the first time I faced this problem it was on 2021.2.1 and I guessed it might be the IntelliJ update that causes this problem and I downgraded it to 2021.1.x which I was using before the update and had no issue with it, but the problem was still there; now I am using 2021.3.2 and still have this problem
project language: I see this problem on both Java and Typescript projects I guess if I am working on a PHP project it may still happen and it is not related to programming language.
about your last question, no I am not connected to any of those modes
By chance, can you check if you can find thread dumps generated by IntelliJ automatically when the UI freezes. They should be in the IDE logs directory:
it is not freezing it, since cpu usage is at 100% everything is supper slow but not freezing, but I’ll try and send u if I can find any dump file
I got a CPU snapshot with the diagnosis tools section inside the IntelliJ.
I just start the CPU profiling when my CPU reached 100% and wait for a couple of seconds then stopped it
hope it helps.
IU-213.6777.52_MetaiR_10.02.2022_03.12.01.zip (2.2 MB)
Thanks for this snapshot, it was really useful.
It looks like SonarLint is indeed the culprit here. For the record there is also some activity related to ‘Microsoft Application Insights’ which is coming from another plugin (maybe Azure Toolkit?).
I identified several problems on our side:
- there are two threads that unnecessarily put pressure on the CPU, I created this ticket to fix that
- to support connecting SonarLint to SonarQube or SonarCloud we use Apache Http Client. The default configuration creates one Java thread per CPU-thread. You can see in the snapshot 24 threads, from
http-client-dispatch-24. I don’t know yet if this number could be reduced (I created this ticket to investigate). In the snapshot you can also see that each thread is waiting and consuming a lot of CPU at the same time:
When going into detail for each thread, it seems they are all blocking in some native code:
I found similar bugs in other products or in the JDK. This ticket mentions the same problem appearing after waking up the PC. What exact JDK version are you using ? Could you maybe try with a more recent version to check if it fixes the issue ?
some notes about things you mentioned:
I think the Microsoft plugin must be Github Copilot since I use it and don’t think any other plugin that I use came from Microsoft. can it be a conflict?
my intellij java version information:
Runtime version: 11.0.13+7-b1751.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
I tried intellij with JDK 17 but since some deprecated APIs are removed the whole intellij UI is buggy
(if you can manage to run intellij by doing some hacks because it won’t be lunch normally) and I can’t work with
is it going to be fixed in the upcoming update? and is there anything else I can do to help this issue? @Damien_Urruty @Julien_HENRY
no updates on this thread?
Your thread is still on our radar. I started a discussion on the Apache HTTP client mailing list. Looks like the best thing to do is to write a small reproducer to narrow down the problem.
I extracted the client initialization section that I think is responsible of the issue into this small repository. Could you give it a try on your side ? If you do, could you try with the JBR and a normal JDK ? Also make sure that SonarLint is not running at the same time. I will also try on my box.
A couple more questions: what is the exact version of Windows you are using ? Does the issue happen only after waking up the PC, or also randomly when you are using it in normal conditions ?
We could provide some kind of workaround for that, like make sure we reduce the number of occupied cores. Some cores would still be at 100% because of the bug though, so we can only reduce the effect of the bug, not make it disappear. If you have time could you test this version where max 3 cores should be at 100% in case the bug happens ? You can find how to install it here.
first of all thanks for your efforts.
for the first part, I didn’t quite understand what to do, I saw your repository; do you want me to only run it in my system with JVM you mentioned, that’s all?
about your questions:
- I have this problem with both Windows 10 and 11, my current windows 10 build is 10.0.19044.1499 but I went through several updates until now.
- no, it happens randomly, actually, I think it might not relate to the waking up the system; the only thing that I am certain of right now is that it always happens after working with IntelliJ for a while
and for the last part, since it is super annoying and makes my PC super slow I will appreciate any workaround and will install your version to test it, I’ll post the results.
--------- update -------
I installed the version u mentioned and after a while I see my CPU usage stuck at 20% and never comes out and it is all because of IntelliJ; after checking my task manager and performance monitoring section, I saw 3 threads are working near 100% (like 90%) and 2 more threads are working hard but they go up and down more frequently. I attached a picture for a better understanding. I run a CPU profiling too and attached the result; hope it helps
About the reproducer project that I created, the idea is to let it run forever and see if you reproduce the problem (CPU at 100%). It’s a simple project where I just create a HTTP client without using it. If we don’t reproduce I will modify the project to trigger some periodic requests.
About the results you observed with the specific debug version, that’s what I was expecting. As I explained above I can’t make the problem completely disappear without finding the root cause, all I can do for now is reduce the number of CPUs involved.
Let me know the results and if the problem manifests with the reproducer project.
And thanks for helping us with this!
first of all sorry for the delay, it is almost Norooz in here (Iranian new year) and I have been super busy wrapping up many things.
I run your repo multiple times for more than 1 hour each but I didn’t catch any suspicious CPU activity.
since I am the only one having this problem past 5 months and I am also living in Iran I have this theory; as you may know, Iran is a restricted area for many cloud APIs (unfortunately), so are u happening to use any restricted (for example google cloud, etc) and didn’t handle connection refuse, 403 erros, etc?
If you are not connecting your SonarLint to SonarQube or SonarCloud, it means the only HTTP requests should be related to our telemetry. Maybe a quick way to check that would be that you temporarily disable telemetry.
You can go to Settings > Tools > SonarLint > About and untick Share anonymous SonarLint statistics. Could you try that, restart the IDE and check if you still observe the CPU spike ?
@Damien_Urruty sure, I’ll post the result in few days
@Damien_Urruty unfortunately it didn’t help,
so what now?
@Damien_Urruty is there anything else I can do to fix this issue, it is very annoying
Hi @MetaiR, let’s continue investigating
First I created this ticket to keep track of this problem.
Then we can try 3 other things:
- as I still want to isolate a reproducer project, I wrote a simple IntelliJ plugin containing only what I think is causing the problem. Could you download this plugin and install it in your IDE (Please remove SonarLint while you let it run):
ApacheBugReproducerPlugin-0.0.1.zip (1.9 MB)
you could also try to run again the reproducer project I gave you earlier in this thread, but this time with the JBR you are currently using in IntelliJ. This might be what triggers the issue.
you could try to run your IntelliJ with a normal JDK (not the JBR), this is documented here: Running IntelliJ IDEA with JDK 17 for Better Render Performance with Metal · Mustafa Akın
As a side note, a new version of the JBR based on Java 17 should land on IntelliJ 2022.2 (see here), so hopefully the problem will be resolved at this time.
Could you please send me some feedback about all those points ?