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

java server refreshing the workspace (cleaning and building) for each restart which is taking a lot of time #2222

Closed
bitsInnovate00 opened this issue Nov 19, 2021 · 13 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1948

Comments

@bitsInnovate00
Copy link

[vscode java server refreshing the workspace (cleaning and building) for each restart which is taking a lot of time]

Environment
  • Operating System: Windows 10
  • JDK version: JDK 11
  • Visual Studio Code version: 1.61.2
  • Java extension version: v0.18.6
  • Java Debugger extension version: v0.36.0
Steps To Reproduce

Please refer the jira. As per the direction , creating the issue in vscode-java
I have a workspace with 5 maven projects which is already refreshed by the vscode java server. But if I simply restart the workspace, its again repeating the workspace refreshment with cleaning and building which is taking a lot of CPU and time. Why its redoing the same thing again and again

[attach a sample project reproducing the error]
attach logs

Current Result

The workspace restart is consuming a lot of CPU and time for the vscode java server for doing the workspace refresh

Expected Result

The worspace should refresh and restart very quickly

Additional Informations

NA

@rgrunber
Copy link
Member

Is the code base available anywhere to try to reproduce this ? @fbricon are there any enhancement requests you're aware of on JDT-LS or m2e to allow a Maven import to happen without also doing a project rebuild ?

@snjeza
Copy link
Contributor

snjeza commented Nov 20, 2021

@rgrunber
Copy link
Member

@bitsInnovate00 @rgrunber Could you, please, check https://github.com/snjeza/vscode-test/raw/master/java-1.1.0.vsix ?

I'm not sure if your fix improves anything for me. If I import lemminx (as an example), it takes about 30s with or without your vsix. In fact, I can see that new classfiles are still generated on import, and the build seems to happen as well.

I guess the problem is a user/process could easily modify the sources between the language server shutting off and starting back up, so it makes sense to rebuild. Disabling java.autobuild.enabled can probably speed things up, but then one has to re-enable it immediately after to ensure subsequent edits are caught.

@snjeza
Copy link
Contributor

snjeza commented Nov 23, 2021

@rgrunber Could you, please, try spring-petclinic?

@mozhuanzuojing
Copy link

@bitsInnovate00 @rgrunber Could you, please, check https://github.com/snjeza/vscode-test/raw/master/java-1.1.0.vsix ?

@snjeza I just used your 1.1.0 for testing and it has fixed the problem. thank you very much.

@mozhuanzuojing
Copy link

@bitsInnovate00 @rgrunber Could you, please, check https://github.com/snjeza/vscode-test/raw/master/java-1.1.0.vsix ?

@snjeza . version 1.0.0 reproduced this same problem with another #2071, but your 1.1.0 fix it.

@rgrunber
Copy link
Member

FWIW, I tried with spring-petclinic initially and noticed there was some improvement in the time it takes to finish the build (and get to ServiceReady). I just didn't see it when I tried lemminx so figured maybe it was some other cause. I'll try again more thoroughly.

@snjeza
Copy link
Contributor

snjeza commented Nov 23, 2021

I just didn't see it when I tried lemminx...

@rgrunber could you, please, check https://github.com/snjeza/vscode-test/raw/master/java-1.1.1.vsix with enabled and disabled the java.autobuild.enabled property?

@rgrunber
Copy link
Member

With java.autobuild.enabled:false, with/without this change, a workspace build takes about ~15s when the LS workspace is cleaned and ~5s if just re-opening the workspace. When I time the clean workspace job, it seems to take ~2s so there definitely is some improvement by not having it run all the time.

@snjeza
Copy link
Contributor

snjeza commented Nov 23, 2021

@rgrunber Could you, please, test with java.autobuild.enabled:true?

@rgrunber
Copy link
Member

With java.autobuild.enabled:true, it's about ~25s from a clean workspace, and ~17s. It seems to be about the same for a regular build and your change. Given that the workspace clean happens in a separate thread, I wouldn't be surprised if it cannot really be measured, though maybe it just reduces pressure on the CPU for more intensive projects. Are you seeing the same thing ?

@snjeza
Copy link
Contributor

snjeza commented Nov 24, 2021

@rgrunber When restarting a workspace, Java LS with the PR doesn't run the clean workspace action. See eclipse-jdtls/eclipse.jdt.ls@999001c#diff-f23d0258ce24117c110acd6753e8490a09fbdf0bc039d662bdffe279c8c28469R320
Java Build Status without the PR (for each restart):
rgrunber1

Java Build Status with the PR (for each restart):
rgrunber2

@rgrunber
Copy link
Member

rgrunber commented Nov 24, 2021

I've tried again with lemminx, since maybe spring-petclinic builds too quickly on my machine. It went from ~17s normally, to ~3s with this change. That's definitely a big deal . Yes, I can confirm the "Clean workspace..." doesn't run any longer.

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.

4 participants