Skip to content

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

Closed
eclipse-jdtls/eclipse.jdt.ls
#1948

Description

@bitsInnovate00

[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

Activity

  1. rgrunber commented on Nov 19, 2021

    @rgrunber
    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 ?

  2. snjeza commented on Nov 20, 2021

    @snjeza
    Collaborator
  3. rgrunber commented on Nov 22, 2021

    @rgrunber
    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.

  4. snjeza commented on Nov 23, 2021

    @snjeza
    Collaborator

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

  5. mozhuanzuojing commented on Nov 23, 2021

    @mozhuanzuojing
    Contributor

    @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.

  6. mozhuanzuojing commented on Nov 23, 2021

    @mozhuanzuojing
    Contributor

    @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.

  7. rgrunber commented on Nov 23, 2021

    @rgrunber
    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.

  8. snjeza commented on Nov 23, 2021

    @snjeza
    Collaborator

    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?

  9. rgrunber commented on Nov 23, 2021

    @rgrunber
    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.

  10. snjeza commented on Nov 23, 2021

    @snjeza
    Collaborator

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

  11. rgrunber commented on Nov 24, 2021

    @rgrunber
    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 ?

  12. snjeza commented on Nov 24, 2021

    @snjeza
    Collaborator

    @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

  13. rgrunber commented on Nov 24, 2021

    @rgrunber
    Member

    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.

  14. added this to the Mid November milestone on Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions