Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU 800% #2799

Closed
mozhuanzuojing opened this issue Aug 15, 2023 · 15 comments · Fixed by #2803
Closed

CPU 800% #2799

mozhuanzuojing opened this issue Aug 15, 2023 · 15 comments · Fixed by #2803

Comments

@mozhuanzuojing
Copy link
Contributor

mozhuanzuojing commented Aug 15, 2023

environment:

Version: 1.81.1 (system setup)
Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794
Date: 2023-08-09T22:22:42.175Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621
vscode.java 1.21.0

issue

In normal use, the java plugin occupies a lot of CPU (800%), It lasted half an hour
It feels related to the slow copy-paste, I now write code in two minutes and paste a line of code.

screen

7aaa6f082f88404dbe6e1a599d67959

java log

java log.zip

jfr 【2min】

flight_recording_1707Eclipse11788_1.zip

@rgrunber
Copy link
Contributor

rgrunber commented Aug 15, 2023

Thanks for the jfr file. It definitely helps.

Yes, if something like a paste action is taking a long time (I clearly saw certain delegate commands taking anywhere from 6s-60s) then clearly the language server is busy with some other computations. In regular usage, I only usually see that on project import. There can be a moment where the language server has signalled it's ready to accept requests, but is still busy with certain aspects of the project build. This definitely doesn't seem like that though, since the server is already up and handling requests for some time.

I noticed there were about 12 worker threads, all active at once. That might explain the slowness :

Screenshot from 2023-08-15 17-15-13

Pretty much all but one have a call stack that looks like this :

image

Seems like getIntroduceParameterProposals() from the refactoring proposals is taking a lot of time to compute. Particularly the type hierarchy creation part. Likely just clicking around causes this, as that triggers the code action request.

Is there something about the project that in the workspace that might be causing this ? Is this something new that didn't happen on previous versions ?

@mozhuanzuojing
Copy link
Contributor Author

Likely just clicking around causes this, as that triggers the code action request.

In fact, I only did two copy-paste actions in VSCODE and waited for the JFR result until the end

@mozhuanzuojing
Copy link
Contributor Author

mozhuanzuojing commented Aug 16, 2023

Is this something new that didn't happen on previous versions ?

Yes. It has been running smoothly for three years (in my work) until the last two versions had this problem

@mozhuanzuojing
Copy link
Contributor Author

Is there something about the project that in the workspace that might be causing this ?

I've been using the same project for two years, not quite like it's caused by the project

@mozhuanzuojing
Copy link
Contributor Author

mozhuanzuojing commented Aug 16, 2023

One night later (12 hours), this morning came and did only three copy-paste operations in VSCODE, followed by 3min recording of JFR. But the only difference is that copy-paste is now fast.

823a4e74f1b312cefff1f95a22ff813

jfr 3min

flight_recording_1707Eclipse5255.zip

@rgrunber
Copy link
Contributor

rgrunber commented Aug 16, 2023

  • I see in the original report you're using vscode-java 1.21.0. What's the earliest version of vscode-java you can reproduce this on ?
  • Does anything improve if you set "java.jdt.ls.lombokSupport.enabled": false ?
  • Are you able to share the project on which this issue occurs ? I have not been able to get any of the worker threads to spend as much time in the code action logic as I see spent in the recordings you've provided :\

Even your most recent jfr shows a bunch of worker threads spawned by the language server spending most of their time computing the type hierarchy for the Introduce Parameter... refactoring command. It shouldn't be taking that long.

CC'ing @snjeza in case there is something she may be aware of.

@snjeza
Copy link
Contributor

snjeza commented Aug 16, 2023

I've been using the same project for two years, not quite like it's caused by the project

@mozhuanzuojing could you attach a project example?

@mozhuanzuojing
Copy link
Contributor Author

mozhuanzuojing commented Aug 17, 2023

  • I see in the original report you're using vscode-java 1.21.0. What's the earliest version of vscode-java you can reproduce this on ?

There are no exact tests, but the version was lowered from my colleague's machine before, and at 1.18.0 it was no problem.

@mozhuanzuojing
Copy link
Contributor Author

  • Does anything improve if you set "java.jdt.ls.lombokSupport.enabled": false ?

Tested with this parameter today, and there is no change.

@mozhuanzuojing
Copy link
Contributor Author

mozhuanzuojing commented Aug 17, 2023

  • Are you able to share the project on which this issue occurs ? I have not been able to get any of the worker threads to spend as much time in the code action logic as I see spent in the recordings you've provided :\

@mozhuanzuojing could you attach a project example?


I'm very sorry, the company's internal projects cannot be shared; and because the project (about 5000 java files) and dependent (about 3000 jars) are relatively large, I feel unable to make a sample project.

However, can you add some special logging in vscode.java, so that I can record some specific help information on this basis.

Additional Information:

  • I am using WSL2 environment on windows;
  • In fact, this problem occurs on all machines of my team;
  • I guess the eclipse JDT Index is damaged, resulting in the need to recalculate the structure of the class.
    Or the copied and pasted content is not originally part of the index, causing the index to always fail to hit, and then it is always being calculated.
  • Is it possible to provide a config that turns off the ability to copy-paste parsing imported packages, which I suspect is a bit of a performance issue;
  • I have a little doubt that this problem is related to the sandbox promotion of vscode, but I have not closed the sandbox to verify;
  • Future expectations, I hope that the virtual thread of JDK21 will help.

@snjeza snjeza self-assigned this Aug 17, 2023
@snjeza
Copy link
Contributor

snjeza commented Aug 17, 2023

I think this is an upstream Eclipse issue.
@mozhuanzuojing Could you try VS Code 1.22.1 ?
It uses Java LS master and jdt.core I20230702-0220

@mozhuanzuojing
Copy link
Contributor Author

I think this is an upstream Eclipse issue. @mozhuanzuojing Could you try VS Code 1.22.1 ? It uses Java LS master and jdt.core I20230702-0220

After installing this package, and after copying and pasting in vscode, the change in CPU usage suddenly increased to 1100%, and then gradually decreased to 300%, lasting for more than 5 minutes. The number of stutters when copying and pasting has been reduced a lot.

@snjeza
Copy link
Contributor

snjeza commented Aug 18, 2023

@mozhuanzuojing I can't reproduce this issue.
Could you compare v1.22.1 with v1.18.0?
Does that issue exist in VS Code 1.19.0 and 1.20.0?

@snjeza
Copy link
Contributor

snjeza commented Aug 19, 2023

@mozhuanzuojing Could you try VS Code 1.22.2?
It uses ideas from redhat-developer/vscode-java#3199 (comment)

  • Handle the paste event synchronously in the main thread
  • Optimize the performance of the code actions

@mozhuanzuojing
Copy link
Contributor Author

mozhuanzuojing commented Aug 19, 2023

@mozhuanzuojing Could you try VS Code 1.22.2? It uses ideas from redhat-developer/vscode-java#3199 (comment)

  • Handle the paste event synchronously in the main thread
  • Optimize the performance of the code actions

Using this verison to test on two computers, copy-paste no longer stutters(<2s).
CPU usage averages 100% (one logical processor) for about 3 to 5 minutes before dropping to 0%.
In general, it is not slow if the CPU usage rate lower than 200%.

this is jfr 5min

flight_recording_1707Eclipse6879_2.zip

snjeza added a commit to snjeza/eclipse.jdt.ls that referenced this issue Aug 19, 2023
A related issue - eclipse-jdtls#2799

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
snjeza added a commit to snjeza/eclipse.jdt.ls that referenced this issue Aug 21, 2023
A related issue - eclipse-jdtls#2799

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
@rgrunber rgrunber added this to the End August 2023 milestone Aug 21, 2023
snjeza added a commit to snjeza/eclipse.jdt.ls that referenced this issue Aug 21, 2023
- Handle paste event & smart semicolon detection synchronously (main thread)
- Permit only a single code action to be handled at once
A related issue - eclipse-jdtls#2799

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
rgrunber pushed a commit that referenced this issue Aug 22, 2023
- Handle paste event & smart semicolon detection synchronously (main thread)
- Permit only a single code action to be handled at once
A related issue - #2799

Signed-off-by: Snjezana Peco <snjezana.peco@redhat.com>
@rgrunber rgrunber moved this to ✅ Done in IDE Cloudaptors Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants