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

Maven spring-boot:run slows down live hover hint significantly. #1743

Closed
khe817 opened this issue Dec 14, 2020 · 10 comments
Closed

Maven spring-boot:run slows down live hover hint significantly. #1743

khe817 opened this issue Dec 14, 2020 · 10 comments
Assignees

Comments

@khe817
Copy link

khe817 commented Dec 14, 2020

When I open a Maven Spring Boot project, the Java language server starts up fine, live hover hint works fast (within 20ms - 30ms).
Then I start $ mvn spring-boot:run command in an bash command line window. The language server switches to being very slow with response time for live hover hint around 7000ms:

[Trace - 11:51:59 AM] Sending request 'java/findLinks - (24)'.
Params: {
    "type": "superImplementation",
    "position": {
        "textDocument": {
            "uri": "file:///home/user/.../PublicationIndexController.java"
        },
        "position": {
            "line": 31,
            "character": 13
        }
    }
}

[Trace - 11:52:06 AM] Received response 'java/findLinks - (24)' in 6999ms.
Result: []

Cleaning the Java language server workspace does not fix the issue.

Environment
  • Operating System: WSL v.2 (Window Subsystem in Linux version 2) version "4.19.128-microsoft-standard" inside "Windows_NT x64 10.0.18363"
  • JDK version: 11.0.9.1
  • Visual Studio Code version: 1.52.0
  • Java extension version: 0.72.0
Steps To Reproduce
  1. Start up a Maven Spring Boot project in VSCode with redhat.java extension enabled. Wait for Java language server to finish starting up. Test live hover hint to see that it works normally.
  2. Open an independent bash command line window (does not matter if it's a terminal inside VSCode or outside VSCode) in WSL. Run command $ mvn spring-boot:run. Wait for Spring Boot to finish starting up.
  3. Try live hover hint in VSCode again. This time, it's very slow.
Additional Informations

While Spring Boot is up and running in the WSL bash command line window. I keep seeing this log recurring in Developer Tool console log window:

Extension Host      workbench.desktop.main.js:5009 Extension Host
Debugger attached.  workbench.desktop.main.js:5009 Debugger attached.
@khe817 khe817 changed the title Maven spring-boot:run slows down Java language server's live hover hint significantly. Maven spring-boot:run slows down live hover hint significantly. Dec 14, 2020
@Eskibear
Copy link
Contributor

Exceptions for using WSL 1 rather than WSL 2
Consider using WSL 1 if:

  • Your project files must be stored in the Windows file system. WSL 1 offers faster access to files mounted from Windows.
    If you will be using your WSL Linux distribution to access project files on the Windows file system, and these files cannot be stored on the Linux file system, you will achieve faster performance across the OS files systems by using WSL 1.
  • A project which requires cross-compilation using both Windows and Linux tools on the same files.
    File performance across the Windows and Linux operating systems is faster in WSL 1 than WSL 2, so if you are using Windows applications to access Linux files, you will currently achieve faster performance with WSL 1.

See https://docs.microsoft.com/en-us/windows/wsl/compare-versions#exceptions-for-using-wsl-1-rather-than-wsl-2
What if you run mvn spring-boot:run in WSL 1 or Windows itself (e.g. CMD)?

BTW, Remote WSL is how VS Code recommends for WSL scenarios.

@khe817
Copy link
Author

khe817 commented Dec 15, 2020

Thank you for replying!

I am aware of the issue with slow access in windows file system with wsl2. My project folders are all under linux file system. I open and run my projects under remote wsl extension as recommended already. I believe I have everything runs under wsl2, no cross platform of any kinds that I know of. So I don't think it's the issue with accessing windows file system under wsl2.

This issue happened after I upgraded to the newest vscode version last Friday. Everything worked fine before that. I tried to install previous versions of redhat.java with no improvement.

Any helps will be very much appreciated!

@Eskibear
Copy link
Contributor

I somehow managed to reproduce it in WSL.

CPU: Xeon E5-1620 v4 @ 3.50GHz, 4 cores
RAM: 32GB
OS: Windows 10, Build 19042
VS Code: 1.52.0
Remote WSL Extension: 0.52.0
JDK in WSL: openjdk-11-jdk installed via apt-get
Extensions intalled in WSL: Java Extension Pack
Java Extension: 0.72.0
Sample project: spring-petclinic

At first, it was WSL 1 (although I set default WSL version to 2, it turned out vscode launched version 1).
In my case, after run mvn spring-boot: run in an external WSL terminal, I could feel hovering become slightly slower for some symbols, but still working. When I hovered on type Collection in OwnerController.java#L91, for the fisrt time, it stuck on "Loading...". After retrying hovering for several times, it went back to normal.

Checking the LS log, I find:

[Error - 1:47:35 PM] Dec 15, 2020, 1:47:35 PM Timed out while retrieving the attached javadoc for Collection {key=Ljava/util/Collection<Lorg/springframework/samples/petclinic/owner/Owner;>;} [in Collection.class [in java.util [in <module:java.base>]]] 
Timed out while retrieving the attached javadoc for Collection {key=Ljava/util/Collection<Lorg/springframework/samples/petclinic/owner/Owner;>;} [in Collection.class [in java.util [in <module:java.base>]]] 
Java Model Exception: Java Model Status [Timed out while retrieving the attached javadoc for Collection {key=Ljava/util/Collection<Lorg/springframework/samples/petclinic/owner/Owner;>;} [in Collection.class [in java.util [in <module:java.base>]]] ]
	at org.eclipse.jdt.internal.core.JavaElement.getURLContents(JavaElement.java:931)
	at org.eclipse.jdt.internal.core.BinaryType.getJavadocContents(BinaryType.java:1088)
	at org.eclipse.jdt.internal.core.BinaryType.getAttachedJavadoc(BinaryType.java:1046)
	at org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2.getHTMLContent(JavadocContentAccess2.java:595)
	at org.eclipse.jdt.ls.core.internal.javadoc.JavadocContentAccess2.getMarkdownContentReader(JavadocContentAccess2.java:2506)
	at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeJavadoc(HoverInfoProvider.java:273)
	at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeHover(HoverInfoProvider.java:145)
	at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.computeHover(HoverHandler.java:52)
	at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.hover(HoverHandler.java:41)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$6(JDTLanguageServer.java:552)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Later I switched it to WSL 2 using below commands.

C:\Users\username>wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         1

C:\Users\username>wsl --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.

C:\Users\username>wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         2

And I find it doesn't matter whether I run mvn spring-boot: run or not, the issue just randomly occured when I hover on some symbols for the first time.

@arguser
Copy link

arguser commented Dec 15, 2020

Hello @khe817, I'm experiencing something similar since Friday. I'm not sure if this is related to the Docker Desktop update or the VSCode/VSCode Extension update which also been around Friday. Do you experience slow code navigation and step debugging?

@khe817
Copy link
Author

khe817 commented Dec 15, 2020

@arguser, I experience slow code navigation and step debugging too. Basically, running mvn spring-boot: run somehow slows the Java language server down significantly, which didn't happen before.

Update: Running mvn spring-boot: run slows down TS/JS language server too. I think at this point, it's an issue with VSCode itself, not just redhat.java extension.

@arguser
Copy link

arguser commented Dec 15, 2020

@khe817 I'm trying the previous VSCode version: 1.51.1, going to report back if this work better.

UPDATE: It does definitely work better, go download https://code.visualstudio.com/updates/v1_51

@shanewaz-abbas
Copy link

shanewaz-abbas commented Dec 18, 2020

I am running into the same issue with a spring app. This app is running in remote host using ssh. As soon as I start the debugger everything becomes super slow. Downgrading vscode solves the issue.
This is the result of running top inside the ssh host:

> top
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                          
 2612 xxxxxxx+  20   0 1498564 163416  34016 R 100.0  0.5  14:53.38 node
> ps -p 2612 -o args
/home/xxxxxx/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/node /home/xxxxxx/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/out/bootstrap-fork --type=extensionHost --uriTransformerPath=/home/xxxxxx/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/out/vs/server/uriTransformer.js

@alexdima
Copy link

This might be caused by vscode's new automatic port forwarding feature which scans the remote OS for available ports in order to forward them locally (microsoft/vscode#112843)

@khe817
Copy link
Author

khe817 commented Feb 4, 2021

The issue has been fixed in the newest version of VSCode 1.53.0.

@khe817 khe817 closed this as completed Feb 4, 2021
@shanewaz-abbas
Copy link

Issue still happening for me. Unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants